1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
Index: firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c
===================================================================
--- firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c  (Revision 20060)
+++ firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c  (Arbeitskopie)
@@ -179,6 +179,15 @@
         flip_lcd(yesno);
 }

+static void lcd_window(int xmin, int ymin, int xmax, int ymax)
+{
+    ymin += y_offset;
+    ymax += y_offset;
+    lcd_write_reg(R_HORIZ_RAM_ADDR_POS, (xmax << 8) | xmin);
+    lcd_write_reg(R_VERT_RAM_ADDR_POS,  (ymax << 8) | ymin);
+    lcd_write_reg(R_RAM_ADDR_SET,       (ymin << 8) | xmin);
+}
+
 static void _display_on(void)
 {
     /* Initialisation the display the same way as the original firmware */
@@ -269,17 +278,13 @@
     lcd_write_reg(R_GAMMA_AMP_AVG_ADJ_RES_NEG, 0x0f08);


-    lcd_write_reg(R_RAM_ADDR_SET, 0);
     lcd_write_reg(R_GATE_SCAN_POS, 0);
     lcd_write_reg(R_VERT_SCROLL_CONTROL, 0);
-    
-    lcd_write_reg(R_1ST_SCR_DRV_POS, 219 << 8);
-    lcd_write_reg(R_2ND_SCR_DRV_POS, 219 << 8);

-    lcd_write_reg(R_HORIZ_RAM_ADDR_POS, 175 << 8);
-    lcd_write_reg(R_VERT_RAM_ADDR_POS, 219 << 8);
+    lcd_window(0, 0, LCD_WIDTH-1, LCD_HEIGHT-1);    
+    lcd_write_reg(R_1ST_SCR_DRV_POS, (LCD_HEIGHT-1) << 8);
+    lcd_write_reg(R_2ND_SCR_DRV_POS, (LCD_HEIGHT-1) << 8);

-
     lcd_write_reg(R_DISP_CONTROL1, 0x0037);

     display_on=true;  /* must be done before calling lcd_update() */
@@ -363,18 +368,6 @@
     (void)height;
 }

-static void lcd_window_x(int xmin, int xmax)
-{
-    lcd_write_reg(R_HORIZ_RAM_ADDR_POS, (xmax << 8) | xmin);
-}
-
-static void lcd_window_y(int ymin, int ymax)
-{
-    ymin += y_offset;
-    ymax += y_offset;
-    lcd_write_reg(R_VERT_RAM_ADDR_POS, (ymax << 8) | ymin);
-    lcd_write_reg(R_RAM_ADDR_SET, ymin << 8);
-}
 /* Update the display.
    This must be called after all other LCD functions that change the display. */
 void lcd_update(void)
@@ -386,8 +379,7 @@

     lcd_busy = true;
     /* Set start position and window */
-    lcd_window_x(0, LCD_WIDTH-1);
-    lcd_window_x(0, LCD_HEIGHT-1);
+    lcd_window(0, 0, LCD_WIDTH-1, LCD_HEIGHT-1);

     lcd_write_cmd(R_WRITE_DATA_2_GRAM);

@@ -416,7 +408,7 @@
     if (y + height >= LCD_HEIGHT)
         height = LCD_HEIGHT - y - 1; /* Clip bottom */
     if (y < 0)
-        height += y; y = 0; /* Clip top */
+        height += y, y = 0; /* Clip top */
     if (height <= 0)
         return; /* nothing left to do */

@@ -425,17 +417,16 @@
     lcd_busy = true;

     lcd_write_cmd(R_WRITE_DATA_2_GRAM);
-    lcd_window_x(x, x + width);
-    lcd_window_y(y, ymax);
+    lcd_window(x, y, x+width, ymax);

-    ptr = &lcd_framebuffer[y][x];
+    ptr = (fb_data*)&lcd_framebuffer[y][x];

     do
     {
         lcd_write_data(ptr, width);
         ptr += LCD_WIDTH;
     }
-    while (++y <= ymax);
+    while (++y < ymax);

     lcd_busy = false;
 } /* lcd_update_rect */
@@ -450,8 +441,7 @@

     lcd_write_reg(R_ENTRY_MODE, R_ENTRY_MODE_HORZ);
     /* Set start position and window */
-    lcd_window_x(LCD_WIDTH+1, 1);
-    lcd_window_y(LCD_HEIGHT+1, 1);
+    lcd_window(LCD_WIDTH+1, LCD_HEIGHT+1, LCD_WIDTH+2, LCD_HEIGHT+2);

     lcd_write_cmd(R_WRITE_DATA_2_GRAM);