summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2009-08-30 02:01:45 +0000
committerThomas Martitz <kugel@rockbox.org>2009-08-30 02:01:45 +0000
commit9ed1a154a50fa92a569cefee4e68119efedfa937 (patch)
treeace362e7e6b19a848836cbcfb81e9dc15a247783
parentb783c06362b19d2838e56eb167e8b408c9cdb53d (diff)
downloadrockbox-9ed1a154a50fa92a569cefee4e68119efedfa937.tar.gz
rockbox-9ed1a154a50fa92a569cefee4e68119efedfa937.zip
Samsung YH925: Implement lcd flipping. Although it's a questionable feature, it should enable us to fix the problem that the OF's display is flipped after the Rockbox bootloader.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22554 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/export/config-yh925.h2
-rw-r--r--firmware/target/arm/samsung/yh925/lcd-yh925.c55
2 files changed, 34 insertions, 23 deletions
diff --git a/firmware/export/config-yh925.h b/firmware/export/config-yh925.h
index 87b7a00ccc..73d2fd4fbc 100644
--- a/firmware/export/config-yh925.h
+++ b/firmware/export/config-yh925.h
@@ -58,7 +58,7 @@
58#define DEFAULT_CONTRAST_SETTING 14 /* Match boot contrast */ 58#define DEFAULT_CONTRAST_SETTING 14 /* Match boot contrast */
59 59
60/* define this if you can flip your LCD */ 60/* define this if you can flip your LCD */
61/* todo #define HAVE_LCD_FLIP */ 61#define HAVE_LCD_FLIP
62 62
63/* define this if you can invert the colours on your LCD */ 63/* define this if you can invert the colours on your LCD */
64/* todo #define HAVE_LCD_INVERT */ 64/* todo #define HAVE_LCD_INVERT */
diff --git a/firmware/target/arm/samsung/yh925/lcd-yh925.c b/firmware/target/arm/samsung/yh925/lcd-yh925.c
index 8afcf58bea..6a5e2aa3a0 100644
--- a/firmware/target/arm/samsung/yh925/lcd-yh925.c
+++ b/firmware/target/arm/samsung/yh925/lcd-yh925.c
@@ -30,7 +30,8 @@ static bool power_on;
30/* Is the display turned on? */ 30/* Is the display turned on? */
31static bool display_on; 31static bool display_on;
32/* Amount of vertical offset. Used for flip offset correction/detection. */ 32/* Amount of vertical offset. Used for flip offset correction/detection. */
33static int y_offset; 33static int y_offset = 4;
34static int x_offset = 16;
34/* Reverse flag. Must be remembered when display is turned off. */ 35/* Reverse flag. Must be remembered when display is turned off. */
35static unsigned short disp_control_rev; 36static unsigned short disp_control_rev;
36/* Contrast setting << 8 */ 37/* Contrast setting << 8 */
@@ -78,6 +79,8 @@ static void lcd_display_off(void);
78#define R_GAMMA_AMP_ADJ_POS 0x3a 79#define R_GAMMA_AMP_ADJ_POS 0x3a
79#define R_GAMMA_AMP_ADJ_NEG 0x3b 80#define R_GAMMA_AMP_ADJ_NEG 0x3b
80 81
82#define R_DRV_OUTPUT_CONTROL_NORMAL (1<<9|1<<4|1<<2|1<<0)
83#define R_DRV_OUTPUT_CONTROL_FLIPPED (1<<11|1<<8|1<<5|1<<4|1<<3)
81static inline void lcd_wait_write(void) 84static inline void lcd_wait_write(void)
82{ 85{
83 while (LCD2_PORT & LCD2_BUSY_MASK); 86 while (LCD2_PORT & LCD2_BUSY_MASK);
@@ -156,26 +159,35 @@ void lcd_set_invert_display(bool yesno)
156 lcd_write_reg(R_DISP_CONTROL, 0x0033 | disp_control_rev); 159 lcd_write_reg(R_DISP_CONTROL, 0x0033 | disp_control_rev);
157} 160}
158 161
159
160/* turn the display upside down (call lcd_update() afterwards) */ 162/* turn the display upside down (call lcd_update() afterwards) */
161void lcd_set_flip(bool yesno) 163void lcd_set_flip(bool flip)
162{ 164{
163 /* NOT MODIFIED FOR THE YH-925 */ 165 int r_drv_output_control;
164 166 if (yesno == (y_offset != 4))
165 if (yesno == (y_offset != 0))
166 return; 167 return;
167
168 /* The LCD controller is 132x160 while the LCD itself is 128x160, so we need 168 /* The LCD controller is 132x160 while the LCD itself is 128x160, so we need
169 * to shift the origin by 4 when we flip the LCD */ 169 * to shift the origin by 4 when we flip the LCD
170 y_offset = yesno ? 4 : 0; 170 *
171 * the higher bits are the key bits for flipping */
172 if (flip)
173 {
174 x_offset = 0; y_offset = 0;
175 r_drv_output_control = R_DRV_OUTPUT_CONTROL_FLIPPED;
176 }
177 else
178 {
179 x_offset = 16; y_offset = 4;
180 r_drv_output_control = R_DRV_OUTPUT_CONTROL_NORMAL;
181 }
171 182
172 if (!power_on) 183 if (!power_on)
173 return; 184 return;
174 185
175 /* SCN4-0=000x0 (G1/G160) */ 186 lcd_write_reg(R_1ST_SCR_DRV_POS, ( (LCD_WIDTH + x_offset - 1) << 8) | x_offset);
176 lcd_write_reg(R_GATE_SCAN_START_POS, yesno ? 0x0002 : 0x0000); 187 lcd_write_reg(R_HORIZ_RAM_ADDR_POS, (LCD_HEIGHT - 1) << 8 | 0);
177 /* SM=0, GS=x, SS=x, NL4-0=10011 (G1-G160) */ 188 lcd_write_reg(R_VERT_RAM_ADDR_POS, ((LCD_WIDTH + x_offset- 1) << 8) | x_offset);
178 lcd_write_reg(R_DRV_OUTPUT_CONTROL, yesno ? 0x0213 : 0x0113); 189 lcd_write_reg(R_DRV_OUTPUT_CONTROL, r_drv_output_control );
190 lcd_write_reg(R_ENTRY_MODE, 0x1028);
179} 191}
180 192
181/* LCD init */ 193/* LCD init */
@@ -226,10 +238,10 @@ void lcd_init_device(void)
226 lcd_write_reg(R_GAMMA_GRAD_ADJ_NEG, 0x0001); 238 lcd_write_reg(R_GAMMA_GRAD_ADJ_NEG, 0x0001);
227 lcd_write_reg(R_GATE_SCAN_START_POS, 0x0000); 239 lcd_write_reg(R_GATE_SCAN_START_POS, 0x0000);
228 lcd_write_reg(R_VERT_SCROLL_CONTROL, 0x0000); 240 lcd_write_reg(R_VERT_SCROLL_CONTROL, 0x0000);
229 lcd_write_reg(R_1ST_SCR_DRV_POS, 0xaf10); 241 lcd_write_reg(R_1ST_SCR_DRV_POS, ( (LCD_WIDTH + 16 - 1) << 8) | 16);
230 lcd_write_reg(R_2ND_SCR_DRV_POS, 0x0000); 242 lcd_write_reg(R_2ND_SCR_DRV_POS, 0x0000);
231 lcd_write_reg(R_HORIZ_RAM_ADDR_POS, 0x7f00); /* ((LCD_HEIGHT - 1) << 8 | 0 */ 243 lcd_write_reg(R_HORIZ_RAM_ADDR_POS, (LCD_HEIGHT - 1) << 8 | 0);
232 lcd_write_reg(R_VERT_RAM_ADDR_POS, 0xaf10); /* ((LCD_WIDTH + 16 - 1) << 8) | 16 */ 244 lcd_write_reg(R_VERT_RAM_ADDR_POS, ((LCD_WIDTH + 16- 1) << 8) | 16);
233 lcd_write_reg(R_GAMMA_AMP_ADJ_POS, 0x1600); 245 lcd_write_reg(R_GAMMA_AMP_ADJ_POS, 0x1600);
234 lcd_write_reg(R_GAMMA_AMP_ADJ_NEG, 0x0006); 246 lcd_write_reg(R_GAMMA_AMP_ADJ_NEG, 0x0006);
235 lcd_write_reg(R_DISP_CONTROL, 0x0104); 247 lcd_write_reg(R_DISP_CONTROL, 0x0104);
@@ -266,12 +278,11 @@ void lcd_init_device(void)
266#endif 278#endif
267 279
268 /* only these bits are needed from the OF init */ 280 /* only these bits are needed from the OF init */
269 lcd_write_reg(R_DRV_OUTPUT_CONTROL, 0x0215); 281 lcd_write_reg(R_DRV_OUTPUT_CONTROL, R_DRV_OUTPUT_CONTROL_NORMAL);
270 lcd_write_reg(R_ENTRY_MODE, 0x1028); 282 lcd_write_reg(R_ENTRY_MODE, 0x1028);
271 283
272 power_on = true; 284 power_on = true;
273 display_on = true; 285 display_on = true;
274 y_offset = 0;
275 disp_control_rev = 0x0004; 286 disp_control_rev = 0x0004;
276 lcd_contrast = DEFAULT_CONTRAST_SETTING << 8; 287 lcd_contrast = DEFAULT_CONTRAST_SETTING << 8;
277} 288}
@@ -599,10 +610,10 @@ void lcd_update_rect(int x0, int y0, int width, int height)
599 y1 = LCD_HEIGHT-1; 610 y1 = LCD_HEIGHT-1;
600 611
601 /* The LCD is actually 128x160 rotated 90 degrees */ 612 /* The LCD is actually 128x160 rotated 90 degrees */
602 lcd_x0 = (LCD_HEIGHT - 1) - y1 + 4; 613 lcd_x0 = (LCD_HEIGHT - 1) - y1 + y_offset;
603 lcd_x1 = (LCD_HEIGHT - 1) - y0 + 4; 614 lcd_x1 = (LCD_HEIGHT - 1) - y0 + y_offset;
604 lcd_y0 = x0 + 16; 615 lcd_y0 = x0 + x_offset;
605 lcd_y1 = x1 + 16; 616 lcd_y1 = x1 + x_offset;
606 617
607 /* set the drawing window */ 618 /* set the drawing window */
608 lcd_write_reg(R_HORIZ_RAM_ADDR_POS, (lcd_x1 << 8) | lcd_x0); 619 lcd_write_reg(R_HORIZ_RAM_ADDR_POS, (lcd_x1 << 8) | lcd_x0);