summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcin Bukat <marcin.bukat@gmail.com>2010-05-10 12:36:58 +0000
committerMarcin Bukat <marcin.bukat@gmail.com>2010-05-10 12:36:58 +0000
commit4fad74e6f6c80045803d8368f4d816341a83736e (patch)
tree1784e9060becd400f67a4961e2627ff53f2816d8
parent45c2a6d3146aa4a40bf7f4bcc529d4e2f0d1cb17 (diff)
downloadrockbox-4fad74e6f6c80045803d8368f4d816341a83736e.tar.gz
rockbox-4fad74e6f6c80045803d8368f4d816341a83736e.zip
HD200 - Remove checks if driver is initialized. lcd_init_device() is always called first.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25928 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/target/coldfire/mpio/hd200/lcd-hd200.c120
1 files changed, 49 insertions, 71 deletions
diff --git a/firmware/target/coldfire/mpio/hd200/lcd-hd200.c b/firmware/target/coldfire/mpio/hd200/lcd-hd200.c
index f3e9eef03b..46509bc49a 100644
--- a/firmware/target/coldfire/mpio/hd200/lcd-hd200.c
+++ b/firmware/target/coldfire/mpio/hd200/lcd-hd200.c
@@ -54,7 +54,6 @@
54static bool cached_invert = false; 54static bool cached_invert = false;
55static bool cached_flip = false; 55static bool cached_flip = false;
56static int cached_contrast = DEFAULT_CONTRAST_SETTING; 56static int cached_contrast = DEFAULT_CONTRAST_SETTING;
57bool lcd_initialized = false;
58 57
59/*** hardware configuration ***/ 58/*** hardware configuration ***/
60int lcd_default_contrast(void) 59int lcd_default_contrast(void)
@@ -65,12 +64,10 @@ int lcd_default_contrast(void)
65void lcd_powersave(bool on) 64void lcd_powersave(bool on)
66{ 65{
67/* What is the point of having else construct here? */ 66/* What is the point of having else construct here? */
68 if(lcd_initialized) { 67 if (on)
69 if (on) 68 lcd_write_command(LCD_SET_POWER_SAVE | 1);
70 lcd_write_command(LCD_SET_POWER_SAVE | 1); 69 else
71 else 70 lcd_write_command(LCD_SET_POWER_SAVE | 1);
72 lcd_write_command(LCD_SET_POWER_SAVE | 1);
73 }
74} 71}
75 72
76void lcd_set_contrast(int val) 73void lcd_set_contrast(int val)
@@ -81,15 +78,13 @@ void lcd_set_contrast(int val)
81 val = MAX_CONTRAST_SETTING; 78 val = MAX_CONTRAST_SETTING;
82 79
83 cached_contrast = val; 80 cached_contrast = val;
84 if(lcd_initialized) 81 lcd_write_command_e(LCD_SET_VOLUME, val);
85 lcd_write_command_e(LCD_SET_VOLUME, val);
86} 82}
87 83
88void lcd_set_invert_display(bool yesno) 84void lcd_set_invert_display(bool yesno)
89{ 85{
90 cached_invert = yesno; 86 cached_invert = yesno;
91 if(lcd_initialized) 87 lcd_write_command(LCD_REVERSE | yesno);
92 lcd_write_command(LCD_REVERSE | yesno);
93 88
94} 89}
95 90
@@ -97,29 +92,24 @@ void lcd_set_invert_display(bool yesno)
97void lcd_set_flip(bool yesno) 92void lcd_set_flip(bool yesno)
98{ 93{
99 cached_flip = yesno; 94 cached_flip = yesno;
100 if(lcd_initialized) 95 if(yesno)
101 { 96 {
102 if(yesno) 97 lcd_write_command(LCD_SELECT_ADC | 1);
103 { 98 lcd_write_command(LCD_SELECT_SHL | 0);
104 lcd_write_command(LCD_SELECT_ADC | 1); 99 lcd_write_command_e(LCD_SET_COM0, 0);
105 lcd_write_command(LCD_SELECT_SHL | 0); 100 }
106 lcd_write_command_e(LCD_SET_COM0, 0); 101 else
107 } 102 {
108 else 103 lcd_write_command(LCD_SELECT_ADC | 0);
109 { 104 lcd_write_command(LCD_SELECT_SHL | 8);
110 lcd_write_command(LCD_SELECT_ADC | 0); 105 lcd_write_command_e(LCD_SET_COM0, 0);
111 lcd_write_command(LCD_SELECT_SHL | 8);
112 lcd_write_command_e(LCD_SET_COM0, 0);
113 }
114 } 106 }
115
116} 107}
117 108
118void lcd_shutdown(void) 109void lcd_shutdown(void)
119{ 110{
120 /* Set power save -> Power OFF (VDD - VSS) .. that's it */ 111 /* Set power save -> Power OFF (VDD - VSS) .. that's it */
121 if (lcd_initialized) 112 lcd_write_command(LCD_SET_POWER_SAVE | 1);
122 lcd_write_command(LCD_SET_POWER_SAVE | 1);
123} 113}
124 114
125void lcd_init_device(void) 115void lcd_init_device(void)
@@ -155,9 +145,6 @@ void lcd_init_device(void)
155 lcd_write_command(LCD_CONTROL_POWER | 7); /* All circuits ON */ 145 lcd_write_command(LCD_CONTROL_POWER | 7); /* All circuits ON */
156 lcd_write_command(LCD_DISPLAY_ON | 1); /* display on */ 146 lcd_write_command(LCD_DISPLAY_ON | 1); /* display on */
157 147
158 /* Ok we are ready */
159 lcd_initialized = true;
160
161 lcd_set_flip(cached_flip); 148 lcd_set_flip(cached_flip);
162 lcd_set_contrast(cached_contrast); 149 lcd_set_contrast(cached_contrast);
163 lcd_set_invert_display(cached_invert); 150 lcd_set_invert_display(cached_invert);
@@ -171,8 +158,6 @@ void lcd_update(void) ICODE_ATTR;
171void lcd_update(void) 158void lcd_update(void)
172{ 159{
173 int y; 160 int y;
174 if(!lcd_initialized)
175 return;
176 161
177 for(y = 0;y < LCD_FBHEIGHT;y++) 162 for(y = 0;y < LCD_FBHEIGHT;y++)
178 { 163 {
@@ -190,28 +175,26 @@ void lcd_update_rect(int x, int y, int width, int height)
190{ 175{
191 int ymax; 176 int ymax;
192 177
193 if (!lcd_initialized) 178 /* The Y coordinates have to work on even 8 pixel rows */
194 return; 179 ymax = (y + height-1) >> 3;
195 180 y >>= 3;
196 181
197 /* The Y coordinates have to work on even 8 pixel rows */ 182 if (x + width > LCD_WIDTH)
198 ymax = (y + height-1) >> 3; 183 width = LCD_WIDTH - x;
199 y >>= 3;
200 184
201 if(x + width > LCD_WIDTH) 185 if (width <= 0)
202 width = LCD_WIDTH - x; 186 return; /* nothing left to do, 0 is harmful to lcd_write_data() */
203 if (width <= 0)
204 return; /* nothing left to do, 0 is harmful to lcd_write_data() */
205 if(ymax >= LCD_FBHEIGHT)
206 ymax = LCD_FBHEIGHT-1;
207 187
208 /* Copy specified rectange bitmap to hardware */ 188 if (ymax >= LCD_FBHEIGHT)
209 for (; y <= ymax; y++) 189 ymax = LCD_FBHEIGHT-1;
210 { 190
211 lcd_write_command(LCD_SET_PAGE | y ); 191 /* Copy specified rectange bitmap to hardware */
212 lcd_write_command_e(LCD_SET_COLUMN | ((x >> 4) & 0xf), x & 0x0f); 192 for (; y <= ymax; y++)
213 lcd_write_data (&lcd_framebuffer[y][x], width); 193 {
214 } 194 lcd_write_command(LCD_SET_PAGE | y );
195 lcd_write_command_e(LCD_SET_COLUMN | ((x >> 4) & 0xf), x & 0x0f);
196 lcd_write_data (&lcd_framebuffer[y][x], width);
197 }
215 198
216} 199}
217 200
@@ -223,17 +206,14 @@ void lcd_mono_data(const unsigned char *data, int count);
223void lcd_blit_mono(const unsigned char *data, int x, int by, int width, 206void lcd_blit_mono(const unsigned char *data, int x, int by, int width,
224 int bheight, int stride) 207 int bheight, int stride)
225{ 208{
226 if (lcd_initialized) 209 while (bheight--)
227 { 210 {
228 while (bheight--) 211 lcd_write_command(LCD_SET_PAGE | (by & 0xf));
229 { 212 lcd_write_command_e(LCD_SET_COLUMN | ((x >> 4) & 0xf), x & 0xf);
230 lcd_write_command(LCD_SET_PAGE | (by & 0xf));
231 lcd_write_command_e(LCD_SET_COLUMN | ((x >> 4) & 0xf), x & 0xf);
232 213
233 lcd_mono_data(data, width); 214 lcd_mono_data(data, width);
234 data += stride; 215 data += stride;
235 by++; 216 by++;
236 }
237 } 217 }
238} 218}
239 219
@@ -245,19 +225,17 @@ void lcd_grey_data(unsigned char *values, unsigned char *phases, int count);
245void lcd_blit_grey_phase(unsigned char *values, unsigned char *phases, 225void lcd_blit_grey_phase(unsigned char *values, unsigned char *phases,
246 int x, int by, int width, int bheight, int stride) 226 int x, int by, int width, int bheight, int stride)
247{ 227{
248 if (lcd_initialized) 228 stride <<= 3; /* 8 pixels per block */
229
230 while (bheight--)
249 { 231 {
250 stride <<= 3; /* 8 pixels per block */ 232 lcd_write_command(LCD_SET_PAGE | (by & 0xf));
251 while (bheight--) 233 lcd_write_command_e(LCD_SET_COLUMN | ((x >> 4) & 0xf), x & 0xf);
252 {
253 lcd_write_command(LCD_SET_PAGE | (by & 0xf));
254 lcd_write_command_e(LCD_SET_COLUMN | ((x >> 4) & 0xf), x & 0xf);
255 234
256 lcd_grey_data(values, phases, width); 235 lcd_grey_data(values, phases, width);
257 values += stride; 236 values += stride;
258 phases += stride; 237 phases += stride;
259 by++; 238 by++;
260 }
261 } 239 }
262} 240}
263 241