Don't set CONFIG_CPU for __PCTOOL__, to avoid wrong asm
[maemo-rb.git] / firmware / export / lcd-remote.h
blob1bb19a5cfaaee91e23a85f38d9d5f718d52756ff
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2005 by Richard S. La Charité
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 #ifndef __LCD_REMOTE_H__
23 #define __LCD_REMOTE_H__
25 #include <stdbool.h>
26 #include "cpu.h"
27 #include "config.h"
28 #include "lcd.h"
30 #ifdef HAVE_REMOTE_LCD /* Not for the players with *only* a remote LCD (m3) */
32 #if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
33 #define REMOTETYPE_UNPLUGGED 0
34 #define REMOTETYPE_H100_LCD 1
35 #define REMOTETYPE_H300_LCD 2
36 #define REMOTETYPE_H300_NONLCD 3
37 int remote_type(void);
38 #endif
40 #define STYLE_DEFAULT 0x00000000
41 #define STYLE_INVERT 0x20000000
43 #if LCD_REMOTE_DEPTH <= 8
44 #if (LCD_REMOTE_PIXELFORMAT == VERTICAL_INTERLEAVED) \
45 || (LCD_REMOTE_PIXELFORMAT == HORIZONTAL_INTERLEAVED)
46 typedef unsigned short fb_remote_data;
47 #define FB_RDATA_SZ 2
48 #else
49 typedef unsigned char fb_remote_data;
50 #define FB_RDATA_SZ 1
51 #endif
52 #elif LCD_DEPTH <= 16
53 typedef unsigned short fb_remote_data;
54 #define FB_RDATA_SZ 2
55 #else
56 typedef unsigned long fb_remote_data;
57 #define FB_RDATA_SZ 4
58 #endif
60 #if LCD_REMOTE_DEPTH > 1 /* greyscale - 8 bit max */
61 #ifdef HAVE_LCD_COLOR
62 extern unsigned lcd_remote_color_to_native(unsigned color);
63 #endif
65 #define LCD_REMOTE_MAX_LEVEL ((1 << LCD_REMOTE_DEPTH) - 1)
66 /**
67 * On 2 bit for example (y >> (8-DEPTH)) = (y >> 6) = y/64 gives:
68 * |000-063|064-127|128-191|192-255|
69 * | 0 | 1 | 2 | 3 |
71 #define LCD_REMOTE_BRIGHTNESS(y) ((y) >> (8-LCD_REMOTE_DEPTH))
73 #define LCD_REMOTE_BLACK LCD_REMOTE_BRIGHTNESS(0)
74 #define LCD_REMOTE_DARKGRAY LCD_REMOTE_BRIGHTNESS(85)
75 #define LCD_REMOTE_LIGHTGRAY LCD_REMOTE_BRIGHTNESS(170)
76 #define LCD_REMOTE_WHITE LCD_REMOTE_BRIGHTNESS(255)
77 #define LCD_REMOTE_DEFAULT_FG LCD_REMOTE_BLACK
78 #define LCD_REMOTE_DEFAULT_BG LCD_REMOTE_WHITE
79 #endif
81 /* Frame buffer dimensions (format checks only cover existing targets!) */
82 #if LCD_REMOTE_DEPTH == 1
83 #define LCD_REMOTE_FBHEIGHT ((LCD_REMOTE_HEIGHT+7)/8)
84 #elif LCD_REMOTE_DEPTH == 2
85 #if LCD_REMOTE_PIXELFORMAT == VERTICAL_INTERLEAVED
86 #define LCD_REMOTE_FBHEIGHT ((LCD_REMOTE_HEIGHT+7)/8)
87 #endif
88 #endif /* LCD_REMOTE_DEPTH */
89 /* Set defaults if not defined different yet. The defaults apply to both
90 * dimensions for LCD_REMOTE_DEPTH >= 8 */
91 #ifndef LCD_REMOTE_FBWIDTH
92 #define LCD_REMOTE_FBWIDTH LCD_REMOTE_WIDTH
93 #endif
94 #ifndef LCD_REMOTE_FBHEIGHT
95 #define LCD_REMOTE_FBHEIGHT LCD_REMOTE_HEIGHT
96 #endif
98 /* The actual framebuffer */
99 extern fb_remote_data *lcd_remote_framebuffer;
100 extern fb_remote_data lcd_remote_static_framebuffer[LCD_REMOTE_FBHEIGHT][LCD_REMOTE_FBWIDTH];
101 #define FBREMOTEADDR(x, y) (lcd_remote_framebuffer + ((y) * LCD_REMOTE_FBWIDTH) + (x))
102 #define FRAMEBUFFER_REMOTE_SIZE (sizeof(lcd_remote_static_framebuffer))
104 #if LCD_REMOTE_DEPTH > 1
105 extern void lcd_remote_set_foreground(unsigned foreground);
106 extern unsigned lcd_remote_get_foreground(void);
107 extern void lcd_remote_set_background(unsigned background);
108 extern unsigned lcd_remote_get_background(void);
109 extern void lcd_remote_set_drawinfo(int mode, unsigned foreground,
110 unsigned background);
111 void lcd_remote_set_backdrop(fb_remote_data* backdrop);
112 fb_remote_data* lcd_remote_get_backdrop(void);
114 extern void lcd_remote_mono_bitmap_part(const unsigned char *src, int src_x,
115 int src_y, int stride, int x, int y,
116 int width, int height);
117 extern void lcd_remote_mono_bitmap(const unsigned char *src, int x, int y,
118 int width, int height);
119 extern void lcd_remote_bitmap_transparent_part(const fb_remote_data *src,
120 int src_x, int src_y,
121 int stride, int x, int y,
122 int width, int height);
123 extern void lcd_bitmap_remote_transparent(const fb_remote_data *src, int x,
124 int y, int width, int height);
125 #else /* LCD_REMOTE_DEPTH == 1 */
126 #define lcd_remote_mono_bitmap lcd_remote_bitmap
127 #define lcd_remote_mono_bitmap_part lcd_remote_bitmap_part
128 #endif /* LCD_REMOTE_DEPTH */
130 /* common functions */
131 void lcd_remote_init(void);
132 void lcd_remote_write_command(int cmd);
133 void lcd_remote_write_command_ex(int cmd, int data);
134 void lcd_remote_write_data(const fb_remote_data *data, int count);
135 extern void lcd_remote_set_framebuffer(fb_remote_data *fb);
137 extern void lcd_remote_bitmap_part(const fb_remote_data *src, int src_x,
138 int src_y, int stride, int x, int y,
139 int width, int height);
140 extern void lcd_remote_bitmap(const fb_remote_data *src, int x, int y,
141 int width, int height);
143 /* Low-level drawing function types */
144 typedef void lcd_remote_pixelfunc_type(int x, int y);
145 typedef void lcd_remote_blockfunc_type(fb_remote_data *address, unsigned mask,
146 unsigned bits);
148 /* low level drawing function pointer arrays */
149 #if LCD_REMOTE_DEPTH > 1
150 extern lcd_remote_pixelfunc_type* const *lcd_remote_pixelfuncs;
151 extern lcd_remote_blockfunc_type* const *lcd_remote_blockfuncs;
152 #else
153 extern lcd_remote_pixelfunc_type* const lcd_remote_pixelfuncs[8];
154 extern lcd_remote_blockfunc_type* const lcd_remote_blockfuncs[8];
155 #endif
157 #endif /* HAVE_LCD_REMOTE */
159 #ifdef HAVE_REMOTE_LCD_TICKING
160 void lcd_remote_emireduce(bool state);
161 #endif
163 void lcd_remote_init_device(void);
164 void lcd_remote_on(void);
165 void lcd_remote_off(void);
167 extern bool remote_initialized;
168 bool remote_detect(void);
170 extern void lcd_remote_init(void);
171 extern int lcd_remote_default_contrast(void);
172 extern void lcd_remote_set_contrast(int val);
174 extern void lcd_remote_set_viewport(struct viewport* vp);
175 extern void lcd_remote_clear_display(void);
176 extern void lcd_remote_clear_viewport(void);
177 extern void lcd_remote_puts(int x, int y, const unsigned char *str);
178 extern void lcd_remote_putsf(int x, int y, const unsigned char *fmt, ...);
179 extern void lcd_remote_puts_style(int x, int y, const unsigned char *str,
180 int style);
181 extern void lcd_remote_puts_offset(int x, int y, const unsigned char *str,
182 int offset);
183 extern void lcd_remote_puts_style_offset(int x, int y, const unsigned char *str,
184 int style, int offset);
185 extern void lcd_remote_puts_style_xyoffset(int x, int y, const unsigned char *str,
186 int style, int x_offset, int y_offset);
187 extern void lcd_remote_putc(int x, int y, unsigned short ch);
188 extern void lcd_remote_stop_scroll(void);
189 extern void lcd_remote_scroll_speed(int speed);
190 extern void lcd_remote_scroll_delay(int ms);
191 extern void lcd_remote_puts_scroll(int x, int y, const unsigned char *str);
192 extern void lcd_remote_puts_scroll_style(int x, int y, const unsigned char *str,
193 int style);
194 extern void lcd_remote_puts_scroll_offset(int x, int y,
195 const unsigned char *str, int offset);
196 extern void lcd_remote_puts_scroll_style_offset(int x, int y,
197 const unsigned char *string,
198 int style, int offset);
199 extern void lcd_remote_puts_scroll_style_xyoffset(int x, int y,
200 const unsigned char *string,
201 int style, int x_offset,
202 int y_offset);
204 extern void lcd_remote_update(void);
205 extern void lcd_remote_update_rect(int x, int y, int width, int height);
206 extern void lcd_remote_update_viewport(void);
207 extern void lcd_remote_update_viewport_rect(int x, int y, int width, int height);
209 extern void lcd_remote_set_invert_display(bool yesno);
210 extern void lcd_remote_set_flip(bool yesno);
212 extern void lcd_remote_set_drawmode(int mode);
213 extern int lcd_remote_get_drawmode(void);
214 extern int lcd_remote_getwidth(void);
215 extern int lcd_remote_getheight(void);
216 extern void lcd_remote_setfont(int font);
217 extern int lcd_remote_getfont(void);
218 extern int lcd_remote_getstringsize(const unsigned char *str, int *w, int *h);
220 extern void lcd_remote_drawpixel(int x, int y);
221 extern void lcd_remote_drawline(int x1, int y1, int x2, int y2);
222 extern void lcd_remote_hline(int x1, int x2, int y);
223 extern void lcd_remote_vline(int x, int y1, int y2);
224 extern void lcd_remote_drawrect(int x, int y, int width, int height);
225 extern void lcd_remote_fillrect(int x, int y, int width, int height);
226 extern void lcd_remote_draw_border_viewport(void);
227 extern void lcd_remote_fill_viewport(void);
228 extern void lcd_remote_putsxy(int x, int y, const unsigned char *str);
229 extern void lcd_remote_putsxyf(int x, int y, const unsigned char *fmt, ...);
231 extern void lcd_remote_bidir_scroll(int threshold);
232 extern void lcd_remote_scroll_step(int pixels);
234 extern void lcd_remote_bmp_part(const struct bitmap* bm, int src_x, int src_y,
235 int x, int y, int width, int height);
236 extern void lcd_remote_bmp(const struct bitmap* bm, int x, int y);
238 #endif /* __LCD_REMOTE_H__ */