Refacturate arm version of libmad's synthesis filter. Only two asm macros left, renam...
[kugel-rb.git] / apps / screen_access.c
blob871b1f8a60c15df8b9b3a7eba10ec58db52b528b
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 <lcd.h>
23 #include <lcd-remote.h>
24 #include <scroll_engine.h>
25 #include "backlight.h"
26 #include <font.h>
27 #include <button.h>
28 #include <sprintf.h>
29 #include <settings.h>
30 #include <kernel.h>
31 #include <icons.h>
33 #include "screen_access.h"
34 #include "backdrop.h"
36 /* some helper functions to calculate metrics on the fly */
37 static int screen_helper_getcharwidth(void)
39 #ifdef HAVE_LCD_BITMAP
40 return font_get(lcd_getfont())->maxwidth;
41 #else
42 return 1;
43 #endif
46 static int screen_helper_getcharheight(void)
48 #ifdef HAVE_LCD_BITMAP
49 return font_get(lcd_getfont())->height;
50 #else
51 return 1;
52 #endif
55 static int screen_helper_getnblines(void)
57 int height=screens[0].lcdheight;
58 #ifdef HAVE_LCD_BITMAP
59 if(global_settings.statusbar != STATUSBAR_OFF)
60 height -= STATUSBAR_HEIGHT;
61 #ifdef HAVE_BUTTONBAR
62 if(global_settings.buttonbar && screens[0].has_buttonbar)
63 height -= BUTTONBAR_HEIGHT;
64 #endif
65 #endif
66 return height / screens[0].getcharheight();
69 #if NB_SCREENS == 2
70 static int screen_helper_remote_getcharwidth(void)
72 #ifdef HAVE_LCD_BITMAP
73 return font_get(lcd_remote_getfont())->maxwidth;
74 #else
75 return 1;
76 #endif
79 static int screen_helper_remote_getcharheight(void)
81 #ifdef HAVE_LCD_BITMAP
82 return font_get(lcd_remote_getfont())->height;
83 #else
84 return 1;
85 #endif
88 static int screen_helper_remote_getnblines(void)
90 int height=screens[1].lcdheight;
91 #ifdef HAVE_LCD_BITMAP
92 if(global_settings.statusbar != STATUSBAR_OFF)
93 height -= STATUSBAR_HEIGHT;
94 #ifdef HAVE_BUTTONBAR
95 if(global_settings.buttonbar && screens[1].has_buttonbar)
96 height -= BUTTONBAR_HEIGHT;
97 #endif
98 #endif
99 return height / screens[1].getcharheight();
101 #endif
103 struct screen screens[NB_SCREENS] =
106 .screen_type=SCREEN_MAIN,
107 .lcdwidth=LCD_WIDTH,
108 .lcdheight=LCD_HEIGHT,
109 .depth=LCD_DEPTH,
110 .getnblines=&screen_helper_getnblines,
111 #if defined(HAVE_LCD_COLOR)
112 .is_color=true,
113 #else
114 .is_color=false,
115 #endif
116 #ifdef HAVE_LCD_BITMAP
117 .pixel_format=LCD_PIXELFORMAT,
118 #endif
119 .getcharwidth=screen_helper_getcharwidth,
120 .getcharheight=screen_helper_getcharheight,
121 #if (CONFIG_LED == LED_VIRTUAL)
122 .has_disk_led=false,
123 #elif defined(HAVE_REMOTE_LCD)
124 .has_disk_led=true,
125 #endif
126 .set_viewport=&lcd_set_viewport,
127 .getwidth=&lcd_getwidth,
128 .getheight=&lcd_getheight,
129 .getstringsize=&lcd_getstringsize,
130 #ifdef HAVE_LCD_BITMAP
131 .setfont=&lcd_setfont,
132 .getfont=&lcd_getfont,
133 .mono_bitmap=&lcd_mono_bitmap,
134 .mono_bitmap_part=&lcd_mono_bitmap_part,
135 .set_drawmode=&lcd_set_drawmode,
136 .bitmap=(screen_bitmap_func*)&lcd_bitmap,
137 .bitmap_part=(screen_bitmap_part_func*)&lcd_bitmap_part,
138 #if LCD_DEPTH <= 2
139 /* No transparency yet for grayscale and mono lcd */
140 .transparent_bitmap=(screen_bitmap_func*)&lcd_bitmap,
141 .transparent_bitmap_part=(screen_bitmap_part_func*)&lcd_bitmap_part,
142 #else
143 .transparent_bitmap=(screen_bitmap_func*)&lcd_bitmap_transparent,
144 .transparent_bitmap_part=(screen_bitmap_part_func*)&lcd_bitmap_transparent_part,
145 #endif
146 #if LCD_DEPTH > 1
147 #if defined(HAVE_LCD_COLOR) && defined(LCD_REMOTE_DEPTH) && LCD_REMOTE_DEPTH > 1
148 .color_to_native=&lcd_color_to_native,
149 #endif
150 .get_background=&lcd_get_background,
151 .get_foreground=&lcd_get_foreground,
152 .set_background=&lcd_set_background,
153 .set_foreground=&lcd_set_foreground,
154 #ifdef HAVE_LCD_COLOR
155 .set_selector_start=&lcd_set_selector_start,
156 .set_selector_end=&lcd_set_selector_end,
157 .set_selector_text=&lcd_set_selector_text,
158 #endif
159 #endif /* LCD_DEPTH > 1 */
160 .update_rect=&lcd_update_rect,
161 .update_viewport_rect=&lcd_update_viewport_rect,
162 .fillrect=&lcd_fillrect,
163 .drawrect=&lcd_drawrect,
164 .drawpixel=&lcd_drawpixel,
165 .drawline=&lcd_drawline,
166 .vline=&lcd_vline,
167 .hline=&lcd_hline,
168 .scroll_step=&lcd_scroll_step,
169 .puts_style_offset=&lcd_puts_style_offset,
170 .puts_scroll_style=&lcd_puts_scroll_style,
171 .puts_scroll_style_offset=&lcd_puts_scroll_style_offset,
172 #endif /* HAVE_LCD_BITMAP */
174 #ifdef HAVE_LCD_CHARCELLS
175 .double_height=&lcd_double_height,
176 .putc=&lcd_putc,
177 .get_locked_pattern=&lcd_get_locked_pattern,
178 .define_pattern=&lcd_define_pattern,
179 .unlock_pattern=&lcd_unlock_pattern,
180 .icon=&lcd_icon,
181 #endif /* HAVE_LCD_CHARCELLS */
183 .putsxy=&lcd_putsxy,
184 .puts=&lcd_puts,
185 .putsf=&lcd_putsf,
186 .puts_offset=&lcd_puts_offset,
187 .puts_scroll=&lcd_puts_scroll,
188 .puts_scroll_offset=&lcd_puts_scroll_offset,
189 .scroll_speed=&lcd_scroll_speed,
190 .scroll_delay=&lcd_scroll_delay,
191 .stop_scroll=&lcd_stop_scroll,
192 .clear_display=&lcd_clear_display,
193 .clear_viewport=&lcd_clear_viewport,
194 .scroll_stop=&lcd_scroll_stop,
195 .scroll_stop_line=&lcd_scroll_stop_line,
196 .update=&lcd_update,
197 .update_viewport=&lcd_update_viewport,
198 .backlight_on=&backlight_on,
199 .backlight_off=&backlight_off,
200 .is_backlight_on=&is_backlight_on,
201 .backlight_set_timeout=&backlight_set_timeout,
202 #if LCD_DEPTH > 1
203 .backdrop_load=&backdrop_load,
204 .backdrop_show=&backdrop_show,
205 #endif
206 #ifdef HAVE_BUTTONBAR
207 .has_buttonbar=false,
208 #endif
210 #if NB_SCREENS == 2
212 .screen_type=SCREEN_REMOTE,
213 .lcdwidth=LCD_REMOTE_WIDTH,
214 .lcdheight=LCD_REMOTE_HEIGHT,
215 .depth=LCD_REMOTE_DEPTH,
216 .getnblines=&screen_helper_remote_getnblines,
217 .is_color=false,/* No color remotes yet */
218 .pixel_format=LCD_REMOTE_PIXELFORMAT,
219 .getcharwidth=screen_helper_remote_getcharwidth,
220 .getcharheight=screen_helper_remote_getcharheight,
221 .has_disk_led=false,
222 .set_viewport=&lcd_remote_set_viewport,
223 .getwidth=&lcd_remote_getwidth,
224 .getheight=&lcd_remote_getheight,
225 .getstringsize=&lcd_remote_getstringsize,
226 #if 1 /* all remote LCDs are bitmapped so far */
227 .setfont=&lcd_remote_setfont,
228 .getfont=&lcd_remote_getfont,
229 .mono_bitmap=&lcd_remote_mono_bitmap,
230 .mono_bitmap_part=&lcd_remote_mono_bitmap_part,
231 .bitmap=(screen_bitmap_func*)&lcd_remote_bitmap,
232 .bitmap_part=(screen_bitmap_part_func*)&lcd_remote_bitmap_part,
233 .set_drawmode=&lcd_remote_set_drawmode,
234 #if LCD_REMOTE_DEPTH <= 2
235 /* No transparency yet for grayscale and mono lcd */
236 .transparent_bitmap=(screen_bitmap_func*)&lcd_remote_bitmap,
237 .transparent_bitmap_part=(screen_bitmap_part_func*)&lcd_remote_bitmap_part,
238 /* No colour remotes yet */
239 #endif
240 #if LCD_REMOTE_DEPTH > 1
241 #if defined(HAVE_LCD_COLOR)
242 .color_to_native=&lcd_remote_color_to_native,
243 #endif
244 .get_background=&lcd_remote_get_background,
245 .get_foreground=&lcd_remote_get_foreground,
246 .set_background=&lcd_remote_set_background,
247 .set_foreground=&lcd_remote_set_foreground,
248 #endif /* LCD_REMOTE_DEPTH > 1 */
249 .update_rect=&lcd_remote_update_rect,
250 .update_viewport_rect=&lcd_remote_update_viewport_rect,
251 .fillrect=&lcd_remote_fillrect,
252 .drawrect=&lcd_remote_drawrect,
253 .drawpixel=&lcd_remote_drawpixel,
254 .drawline=&lcd_remote_drawline,
255 .vline=&lcd_remote_vline,
256 .hline=&lcd_remote_hline,
257 .scroll_step=&lcd_remote_scroll_step,
258 .puts_style_offset=&lcd_remote_puts_style_offset,
259 .puts_scroll_style=&lcd_remote_puts_scroll_style,
260 .puts_scroll_style_offset=&lcd_remote_puts_scroll_style_offset,
261 #endif /* 1 */
263 #if 0 /* no charcell remote LCDs so far */
264 .double_height=&lcd_remote_double_height,
265 .putc=&lcd_remote_putc,
266 .get_locked_pattern=&lcd_remote_get_locked_pattern,
267 .define_pattern=&lcd_remote_define_pattern,
268 .icon=&lcd_remote_icon,
269 #endif /* 0 */
270 .putsxy=&lcd_remote_putsxy,
271 .puts=&lcd_remote_puts,
272 .putsf=&lcd_remote_putsf,
273 .puts_offset=&lcd_remote_puts_offset,
274 .puts_scroll=&lcd_remote_puts_scroll,
275 .puts_scroll_offset=&lcd_remote_puts_scroll_offset,
276 .scroll_speed=&lcd_remote_scroll_speed,
277 .scroll_delay=&lcd_remote_scroll_delay,
278 .stop_scroll=&lcd_remote_stop_scroll,
279 .clear_display=&lcd_remote_clear_display,
280 .clear_viewport=&lcd_remote_clear_viewport,
281 .scroll_stop=&lcd_remote_scroll_stop,
282 .scroll_stop_line=&lcd_remote_scroll_stop_line,
283 .update=&lcd_remote_update,
284 .update_viewport=&lcd_remote_update_viewport,
285 .backlight_on=&remote_backlight_on,
286 .backlight_off=&remote_backlight_off,
287 .is_backlight_on=&is_remote_backlight_on,
288 .backlight_set_timeout=&remote_backlight_set_timeout,
290 #if LCD_DEPTH > 1
291 .backdrop_load=&remote_backdrop_load,
292 .backdrop_show=&remote_backdrop_show,
293 #endif
294 #ifdef HAVE_BUTTONBAR
295 .has_buttonbar=false,
296 #endif
298 #endif /* HAVE_REMOTE_LCD */
301 #ifdef HAVE_LCD_BITMAP
302 void screen_clear_area(struct screen * display, int xstart, int ystart,
303 int width, int height)
305 display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
306 display->fillrect(xstart, ystart, width, height);
307 display->set_drawmode(DRMODE_SOLID);
309 #endif