Prepare new, unofficial pandora build
[maemo-rb.git] / firmware / export / lcd-remote.h
blobe2f2ab16ec50f5a1b8656c46e390324c4e3ec277
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
32 #if defined(TARGET_TREE) && !defined(__PCTOOL__)
33 #include "lcd-remote-target.h"
34 #endif
36 #if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
37 #define REMOTETYPE_UNPLUGGED 0
38 #define REMOTETYPE_H100_LCD 1
39 #define REMOTETYPE_H300_LCD 2
40 #define REMOTETYPE_H300_NONLCD 3
41 int remote_type(void);
42 #endif
44 #define STYLE_DEFAULT 0x00000000
45 #define STYLE_INVERT 0x20000000
47 #if LCD_REMOTE_DEPTH <= 8
48 #if (LCD_REMOTE_PIXELFORMAT == VERTICAL_INTERLEAVED) \
49 || (LCD_REMOTE_PIXELFORMAT == HORIZONTAL_INTERLEAVED)
50 typedef unsigned short fb_remote_data;
51 #define FB_RDATA_SZ 2
52 #else
53 typedef unsigned char fb_remote_data;
54 #define FB_RDATA_SZ 1
55 #endif
56 #elif LCD_DEPTH <= 16
57 typedef unsigned short fb_remote_data;
58 #define FB_RDATA_SZ 2
59 #else
60 typedef unsigned long fb_remote_data;
61 #define FB_RDATA_SZ 4
62 #endif
64 /* common functions */
65 void lcd_remote_init(void);
66 void lcd_remote_write_command(int cmd);
67 void lcd_remote_write_command_ex(int cmd, int data);
68 void lcd_remote_write_data(const fb_remote_data *data, int count);
70 /* Low-level drawing function types */
71 typedef void lcd_remote_pixelfunc_type(int x, int y);
72 typedef void lcd_remote_blockfunc_type(fb_remote_data *address, unsigned mask,
73 unsigned bits);
75 #if LCD_REMOTE_DEPTH > 1 /* greyscale - 8 bit max */
76 #ifdef HAVE_LCD_COLOR
77 extern unsigned lcd_remote_color_to_native(unsigned color);
78 #endif
80 #define LCD_REMOTE_MAX_LEVEL ((1 << LCD_REMOTE_DEPTH) - 1)
81 /**
82 * On 2 bit for example (y >> (8-DEPTH)) = (y >> 6) = y/64 gives:
83 * |000-063|064-127|128-191|192-255|
84 * | 0 | 1 | 2 | 3 |
86 #define LCD_REMOTE_BRIGHTNESS(y) ((y) >> (8-LCD_REMOTE_DEPTH))
88 #define LCD_REMOTE_BLACK LCD_REMOTE_BRIGHTNESS(0)
89 #define LCD_REMOTE_DARKGRAY LCD_REMOTE_BRIGHTNESS(85)
90 #define LCD_REMOTE_LIGHTGRAY LCD_REMOTE_BRIGHTNESS(170)
91 #define LCD_REMOTE_WHITE LCD_REMOTE_BRIGHTNESS(255)
92 #define LCD_REMOTE_DEFAULT_FG LCD_REMOTE_BLACK
93 #define LCD_REMOTE_DEFAULT_BG LCD_REMOTE_WHITE
94 #endif
96 /* Frame buffer dimensions (format checks only cover existing targets!) */
97 #if LCD_REMOTE_DEPTH == 1
98 #define LCD_REMOTE_FBHEIGHT ((LCD_REMOTE_HEIGHT+7)/8)
99 #elif LCD_REMOTE_DEPTH == 2
100 #if LCD_REMOTE_PIXELFORMAT == VERTICAL_INTERLEAVED
101 #define LCD_REMOTE_FBHEIGHT ((LCD_REMOTE_HEIGHT+7)/8)
102 #endif
103 #endif /* LCD_REMOTE_DEPTH */
104 /* Set defaults if not defined different yet. The defaults apply to both
105 * dimensions for LCD_REMOTE_DEPTH >= 8 */
106 #ifndef LCD_REMOTE_FBWIDTH
107 #define LCD_REMOTE_FBWIDTH LCD_REMOTE_WIDTH
108 #endif
109 #ifndef LCD_REMOTE_FBHEIGHT
110 #define LCD_REMOTE_FBHEIGHT LCD_REMOTE_HEIGHT
111 #endif
112 /* The actual framebuffer */
113 extern fb_remote_data lcd_remote_framebuffer[LCD_REMOTE_FBHEIGHT][LCD_REMOTE_FBWIDTH];
116 extern void lcd_remote_init(void);
117 extern int lcd_remote_default_contrast(void);
118 extern void lcd_remote_set_contrast(int val);
120 extern void lcd_remote_set_viewport(struct viewport* vp);
121 extern void lcd_remote_clear_display(void);
122 extern void lcd_remote_clear_viewport(void);
123 extern void lcd_remote_puts(int x, int y, const unsigned char *str);
124 extern void lcd_remote_putsf(int x, int y, const unsigned char *fmt, ...);
125 extern void lcd_remote_puts_style(int x, int y, const unsigned char *str,
126 int style);
127 extern void lcd_remote_puts_offset(int x, int y, const unsigned char *str,
128 int offset);
129 extern void lcd_remote_puts_style_offset(int x, int y, const unsigned char *str,
130 int style, int offset);
131 extern void lcd_remote_puts_style_xyoffset(int x, int y, const unsigned char *str,
132 int style, int x_offset, int y_offset);
133 extern void lcd_remote_putc(int x, int y, unsigned short ch);
134 extern void lcd_remote_stop_scroll(void);
135 extern void lcd_remote_scroll_speed(int speed);
136 extern void lcd_remote_scroll_delay(int ms);
137 extern void lcd_remote_puts_scroll(int x, int y, const unsigned char *str);
138 extern void lcd_remote_puts_scroll_style(int x, int y, const unsigned char *str,
139 int style);
140 extern void lcd_remote_puts_scroll_offset(int x, int y,
141 const unsigned char *str, int offset);
142 extern void lcd_remote_puts_scroll_style_offset(int x, int y,
143 const unsigned char *string,
144 int style, int offset);
145 extern void lcd_remote_puts_scroll_style_xyoffset(int x, int y,
146 const unsigned char *string,
147 int style, int x_offset,
148 int y_offset);
150 extern void lcd_remote_update(void);
151 extern void lcd_remote_update_rect(int x, int y, int width, int height);
152 extern void lcd_remote_update_viewport(void);
153 extern void lcd_remote_update_viewport_rect(int x, int y, int width, int height);
155 extern void lcd_remote_set_invert_display(bool yesno);
156 extern void lcd_remote_set_flip(bool yesno);
158 extern void lcd_remote_set_drawmode(int mode);
159 extern int lcd_remote_get_drawmode(void);
160 extern int lcd_remote_getwidth(void);
161 extern int lcd_remote_getheight(void);
162 extern void lcd_remote_setfont(int font);
163 extern int lcd_remote_getfont(void);
164 extern int lcd_remote_getstringsize(const unsigned char *str, int *w, int *h);
166 /* low level drawing function pointer arrays */
167 #if LCD_REMOTE_DEPTH > 1
168 extern lcd_remote_pixelfunc_type* const *lcd_remote_pixelfuncs;
169 extern lcd_remote_blockfunc_type* const *lcd_remote_blockfuncs;
170 #else
171 extern lcd_remote_pixelfunc_type* const lcd_remote_pixelfuncs[8];
172 extern lcd_remote_blockfunc_type* const lcd_remote_blockfuncs[8];
173 #endif
175 extern void lcd_remote_drawpixel(int x, int y);
176 extern void lcd_remote_drawline(int x1, int y1, int x2, int y2);
177 extern void lcd_remote_hline(int x1, int x2, int y);
178 extern void lcd_remote_vline(int x, int y1, int y2);
179 extern void lcd_remote_drawrect(int x, int y, int width, int height);
180 extern void lcd_remote_fillrect(int x, int y, int width, int height);
181 extern void lcd_remote_draw_border_viewport(void);
182 extern void lcd_remote_fill_viewport(void);
183 extern void lcd_remote_bitmap_part(const fb_remote_data *src, int src_x,
184 int src_y, int stride, int x, int y,
185 int width, int height);
186 extern void lcd_remote_bitmap(const fb_remote_data *src, int x, int y,
187 int width, int height);
188 extern void lcd_remote_putsxy(int x, int y, const unsigned char *str);
189 extern void lcd_remote_putsxyf(int x, int y, const unsigned char *fmt, ...);
191 extern void lcd_remote_bidir_scroll(int threshold);
192 extern void lcd_remote_scroll_step(int pixels);
194 #if LCD_REMOTE_DEPTH > 1
195 extern void lcd_remote_set_foreground(unsigned foreground);
196 extern unsigned lcd_remote_get_foreground(void);
197 extern void lcd_remote_set_background(unsigned background);
198 extern unsigned lcd_remote_get_background(void);
199 extern void lcd_remote_set_drawinfo(int mode, unsigned foreground,
200 unsigned background);
201 void lcd_remote_set_backdrop(fb_remote_data* backdrop);
202 fb_remote_data* lcd_remote_get_backdrop(void);
204 extern void lcd_remote_mono_bitmap_part(const unsigned char *src, int src_x,
205 int src_y, int stride, int x, int y,
206 int width, int height);
207 extern void lcd_remote_mono_bitmap(const unsigned char *src, int x, int y,
208 int width, int height);
209 extern void lcd_remote_bitmap_transparent_part(const fb_remote_data *src,
210 int src_x, int src_y,
211 int stride, int x, int y,
212 int width, int height);
213 extern void lcd_bitmap_remote_transparent(const fb_remote_data *src, int x,
214 int y, int width, int height);
215 #else /* LCD_REMOTE_DEPTH == 1 */
216 #define lcd_remote_mono_bitmap lcd_remote_bitmap
217 #define lcd_remote_mono_bitmap_part lcd_remote_bitmap_part
218 #endif /* LCD_REMOTE_DEPTH */
220 #endif
221 #endif /* __LCD_REMOTE_H__ */