Put decoder array into IRAM. Improves Coldfire (h300) performance 218MHz ->102.84...
[kugel-rb.git] / apps / screen_access.c
blobdf071020e5115cad4ef4fd52cdc1863b776a1c34
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2005 by Kevin Ferrare
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #include <stdio.h>
23 #include "config.h"
24 #include <lcd.h>
25 #include <lcd-remote.h>
26 #include <scroll_engine.h>
27 #include <font.h>
28 #include <button.h>
29 #include <settings.h>
30 #include <kernel.h>
31 #include <icons.h>
33 #include "backlight.h"
34 #include "screen_access.h"
35 #include "backdrop.h"
37 /* some helper functions to calculate metrics on the fly */
38 static int screen_helper_getcharwidth(void)
40 #ifdef HAVE_LCD_BITMAP
41 return font_get(lcd_getfont())->maxwidth;
42 #else
43 return 1;
44 #endif
47 static int screen_helper_getcharheight(void)
49 #ifdef HAVE_LCD_BITMAP
50 return font_get(lcd_getfont())->height;
51 #else
52 return 1;
53 #endif
56 static int screen_helper_getnblines(void)
58 int height=screens[0].lcdheight;
59 #ifdef HAVE_LCD_BITMAP
60 if(global_settings.statusbar != STATUSBAR_OFF)
61 height -= STATUSBAR_HEIGHT;
62 #ifdef HAVE_BUTTONBAR
63 if(global_settings.buttonbar && screens[0].has_buttonbar)
64 height -= BUTTONBAR_HEIGHT;
65 #endif
66 #endif
67 return height / screens[0].getcharheight();
70 #if NB_SCREENS == 2
71 static int screen_helper_remote_getcharwidth(void)
73 #ifdef HAVE_LCD_BITMAP
74 return font_get(lcd_remote_getfont())->maxwidth;
75 #else
76 return 1;
77 #endif
80 static int screen_helper_remote_getcharheight(void)
82 #ifdef HAVE_LCD_BITMAP
83 return font_get(lcd_remote_getfont())->height;
84 #else
85 return 1;
86 #endif
89 static int screen_helper_remote_getnblines(void)
91 int height=screens[1].lcdheight;
92 #ifdef HAVE_LCD_BITMAP
93 if(global_settings.statusbar != STATUSBAR_OFF)
94 height -= STATUSBAR_HEIGHT;
95 #ifdef HAVE_BUTTONBAR
96 if(global_settings.buttonbar && screens[1].has_buttonbar)
97 height -= BUTTONBAR_HEIGHT;
98 #endif
99 #endif
100 return height / screens[1].getcharheight();
102 #endif
104 struct screen screens[NB_SCREENS] =
107 .screen_type=SCREEN_MAIN,
108 .lcdwidth=LCD_WIDTH,
109 .lcdheight=LCD_HEIGHT,
110 .depth=LCD_DEPTH,
111 .getnblines=&screen_helper_getnblines,
112 #if defined(HAVE_LCD_COLOR)
113 .is_color=true,
114 #else
115 .is_color=false,
116 #endif
117 #ifdef HAVE_LCD_BITMAP
118 .pixel_format=LCD_PIXELFORMAT,
119 #endif
120 .getcharwidth=screen_helper_getcharwidth,
121 .getcharheight=screen_helper_getcharheight,
122 #if (CONFIG_LED == LED_VIRTUAL)
123 .has_disk_led=false,
124 #elif defined(HAVE_REMOTE_LCD)
125 .has_disk_led=true,
126 #endif
127 .set_viewport=&lcd_set_viewport,
128 .getwidth=&lcd_getwidth,
129 .getheight=&lcd_getheight,
130 .getstringsize=&lcd_getstringsize,
131 #ifdef HAVE_LCD_BITMAP
132 .setfont=&lcd_setfont,
133 .getfont=&lcd_getfont,
134 .mono_bitmap=&lcd_mono_bitmap,
135 .mono_bitmap_part=&lcd_mono_bitmap_part,
136 .set_drawmode=&lcd_set_drawmode,
137 .bitmap=(screen_bitmap_func*)&lcd_bitmap,
138 .bitmap_part=(screen_bitmap_part_func*)&lcd_bitmap_part,
139 #if LCD_DEPTH <= 2
140 /* No transparency yet for grayscale and mono lcd */
141 .transparent_bitmap=(screen_bitmap_func*)&lcd_bitmap,
142 .transparent_bitmap_part=(screen_bitmap_part_func*)&lcd_bitmap_part,
143 #else
144 .transparent_bitmap=(screen_bitmap_func*)&lcd_bitmap_transparent,
145 .transparent_bitmap_part=(screen_bitmap_part_func*)&lcd_bitmap_transparent_part,
146 #endif
147 #if LCD_DEPTH > 1
148 #if defined(HAVE_LCD_COLOR) && defined(LCD_REMOTE_DEPTH) && LCD_REMOTE_DEPTH > 1
149 .color_to_native=&lcd_color_to_native,
150 #endif
151 .get_background=&lcd_get_background,
152 .get_foreground=&lcd_get_foreground,
153 .set_background=&lcd_set_background,
154 .set_foreground=&lcd_set_foreground,
155 #ifdef HAVE_LCD_COLOR
156 .set_selector_start=&lcd_set_selector_start,
157 .set_selector_end=&lcd_set_selector_end,
158 .set_selector_text=&lcd_set_selector_text,
159 #endif
160 #endif /* LCD_DEPTH > 1 */
161 .update_rect=&lcd_update_rect,
162 .update_viewport_rect=&lcd_update_viewport_rect,
163 .fillrect=&lcd_fillrect,
164 .drawrect=&lcd_drawrect,
165 .drawpixel=&lcd_drawpixel,
166 .drawline=&lcd_drawline,
167 .vline=&lcd_vline,
168 .hline=&lcd_hline,
169 .scroll_step=&lcd_scroll_step,
170 .puts_style_offset=&lcd_puts_style_offset,
171 .puts_scroll_style=&lcd_puts_scroll_style,
172 .puts_scroll_style_offset=&lcd_puts_scroll_style_offset,
173 #endif /* HAVE_LCD_BITMAP */
175 #ifdef HAVE_LCD_CHARCELLS
176 .double_height=&lcd_double_height,
177 .putc=&lcd_putc,
178 .get_locked_pattern=&lcd_get_locked_pattern,
179 .define_pattern=&lcd_define_pattern,
180 .unlock_pattern=&lcd_unlock_pattern,
181 .icon=&lcd_icon,
182 #endif /* HAVE_LCD_CHARCELLS */
184 .putsxy=&lcd_putsxy,
185 .puts=&lcd_puts,
186 .putsf=&lcd_putsf,
187 .puts_offset=&lcd_puts_offset,
188 .puts_scroll=&lcd_puts_scroll,
189 .puts_scroll_offset=&lcd_puts_scroll_offset,
190 .scroll_speed=&lcd_scroll_speed,
191 .scroll_delay=&lcd_scroll_delay,
192 .stop_scroll=&lcd_stop_scroll,
193 .clear_display=&lcd_clear_display,
194 .clear_viewport=&lcd_clear_viewport,
195 .scroll_stop=&lcd_scroll_stop,
196 .scroll_stop_line=&lcd_scroll_stop_line,
197 .update=&lcd_update,
198 .update_viewport=&lcd_update_viewport,
199 .backlight_on=&backlight_on,
200 .backlight_off=&backlight_off,
201 .is_backlight_on=&is_backlight_on,
202 .backlight_set_timeout=&backlight_set_timeout,
203 #if LCD_DEPTH > 1
204 .backdrop_load=&backdrop_load,
205 .backdrop_show=&backdrop_show,
206 #endif
207 #ifdef HAVE_BUTTONBAR
208 .has_buttonbar=false,
209 #endif
211 #if NB_SCREENS == 2
213 .screen_type=SCREEN_REMOTE,
214 .lcdwidth=LCD_REMOTE_WIDTH,
215 .lcdheight=LCD_REMOTE_HEIGHT,
216 .depth=LCD_REMOTE_DEPTH,
217 .getnblines=&screen_helper_remote_getnblines,
218 .is_color=false,/* No color remotes yet */
219 .pixel_format=LCD_REMOTE_PIXELFORMAT,
220 .getcharwidth=screen_helper_remote_getcharwidth,
221 .getcharheight=screen_helper_remote_getcharheight,
222 .has_disk_led=false,
223 .set_viewport=&lcd_remote_set_viewport,
224 .getwidth=&lcd_remote_getwidth,
225 .getheight=&lcd_remote_getheight,
226 .getstringsize=&lcd_remote_getstringsize,
227 #if 1 /* all remote LCDs are bitmapped so far */
228 .setfont=&lcd_remote_setfont,
229 .getfont=&lcd_remote_getfont,
230 .mono_bitmap=&lcd_remote_mono_bitmap,
231 .mono_bitmap_part=&lcd_remote_mono_bitmap_part,
232 .bitmap=(screen_bitmap_func*)&lcd_remote_bitmap,
233 .bitmap_part=(screen_bitmap_part_func*)&lcd_remote_bitmap_part,
234 .set_drawmode=&lcd_remote_set_drawmode,
235 #if LCD_REMOTE_DEPTH <= 2
236 /* No transparency yet for grayscale and mono lcd */
237 .transparent_bitmap=(screen_bitmap_func*)&lcd_remote_bitmap,
238 .transparent_bitmap_part=(screen_bitmap_part_func*)&lcd_remote_bitmap_part,
239 /* No colour remotes yet */
240 #endif
241 #if LCD_REMOTE_DEPTH > 1
242 #if defined(HAVE_LCD_COLOR)
243 .color_to_native=&lcd_remote_color_to_native,
244 #endif
245 .get_background=&lcd_remote_get_background,
246 .get_foreground=&lcd_remote_get_foreground,
247 .set_background=&lcd_remote_set_background,
248 .set_foreground=&lcd_remote_set_foreground,
249 #endif /* LCD_REMOTE_DEPTH > 1 */
250 .update_rect=&lcd_remote_update_rect,
251 .update_viewport_rect=&lcd_remote_update_viewport_rect,
252 .fillrect=&lcd_remote_fillrect,
253 .drawrect=&lcd_remote_drawrect,
254 .drawpixel=&lcd_remote_drawpixel,
255 .drawline=&lcd_remote_drawline,
256 .vline=&lcd_remote_vline,
257 .hline=&lcd_remote_hline,
258 .scroll_step=&lcd_remote_scroll_step,
259 .puts_style_offset=&lcd_remote_puts_style_offset,
260 .puts_scroll_style=&lcd_remote_puts_scroll_style,
261 .puts_scroll_style_offset=&lcd_remote_puts_scroll_style_offset,
262 #endif /* 1 */
264 #if 0 /* no charcell remote LCDs so far */
265 .double_height=&lcd_remote_double_height,
266 .putc=&lcd_remote_putc,
267 .get_locked_pattern=&lcd_remote_get_locked_pattern,
268 .define_pattern=&lcd_remote_define_pattern,
269 .icon=&lcd_remote_icon,
270 #endif /* 0 */
271 .putsxy=&lcd_remote_putsxy,
272 .puts=&lcd_remote_puts,
273 .putsf=&lcd_remote_putsf,
274 .puts_offset=&lcd_remote_puts_offset,
275 .puts_scroll=&lcd_remote_puts_scroll,
276 .puts_scroll_offset=&lcd_remote_puts_scroll_offset,
277 .scroll_speed=&lcd_remote_scroll_speed,
278 .scroll_delay=&lcd_remote_scroll_delay,
279 .stop_scroll=&lcd_remote_stop_scroll,
280 .clear_display=&lcd_remote_clear_display,
281 .clear_viewport=&lcd_remote_clear_viewport,
282 .scroll_stop=&lcd_remote_scroll_stop,
283 .scroll_stop_line=&lcd_remote_scroll_stop_line,
284 .update=&lcd_remote_update,
285 .update_viewport=&lcd_remote_update_viewport,
286 .backlight_on=&remote_backlight_on,
287 .backlight_off=&remote_backlight_off,
288 .is_backlight_on=&is_remote_backlight_on,
289 .backlight_set_timeout=&remote_backlight_set_timeout,
291 #if LCD_DEPTH > 1
292 .backdrop_load=&remote_backdrop_load,
293 .backdrop_show=&remote_backdrop_show,
294 #endif
295 #ifdef HAVE_BUTTONBAR
296 .has_buttonbar=false,
297 #endif
299 #endif /* HAVE_REMOTE_LCD */
302 #ifdef HAVE_LCD_BITMAP
303 void screen_clear_area(struct screen * display, int xstart, int ystart,
304 int width, int height)
306 display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
307 display->fillrect(xstart, ystart, width, height);
308 display->set_drawmode(DRMODE_SOLID);
310 #endif