1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2005 by Richard S. La Charité
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
20 #ifndef __LCD_REMOTE_H__
21 #define __LCD_REMOTE_H__
28 #ifdef HAVE_REMOTE_LCD
30 #if defined(TARGET_TREE) && !defined(__PCTOOL__)
31 #include "lcd-remote-target.h"
34 #if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
35 #define REMOTETYPE_UNPLUGGED 0
36 #define REMOTETYPE_H100_LCD 1
37 #define REMOTETYPE_H300_LCD 2
38 #define REMOTETYPE_H300_NONLCD 3
39 int remote_type(void);
42 #define STYLE_DEFAULT 0x00000000
43 #define STYLE_INVERT 0x20000000
45 #if LCD_REMOTE_DEPTH <= 8
46 #if (LCD_REMOTE_PIXELFORMAT == VERTICAL_INTERLEAVED) \
47 || (LCD_REMOTE_PIXELFORMAT == HORIZONTAL_INTERLEAVED)
48 typedef unsigned short fb_remote_data
;
50 typedef unsigned char fb_remote_data
;
53 typedef unsigned short fb_remote_data
;
55 typedef unsigned long fb_remote_data
;
58 /* common functions */
59 void lcd_remote_init(void);
60 void lcd_remote_write_command(int cmd
);
61 void lcd_remote_write_command_ex(int cmd
, int data
);
62 void lcd_remote_write_data(const fb_remote_data
*data
, int count
);
64 /* Low-level drawing function types */
65 typedef void lcd_remote_pixelfunc_type(int x
, int y
);
66 typedef void lcd_remote_blockfunc_type(fb_remote_data
*address
, unsigned mask
,
69 #if LCD_REMOTE_DEPTH > 1 /* greyscale - 8 bit max */
71 extern unsigned lcd_remote_color_to_native(unsigned color
);
74 #define LCD_REMOTE_MAX_LEVEL ((1 << LCD_REMOTE_DEPTH) - 1)
76 * On 2 bit for example (y >> (8-DEPTH)) = (y >> 6) = y/64 gives:
77 * |000-063|064-127|128-191|192-255|
80 #define LCD_REMOTE_BRIGHTNESS(y) ((y) >> (8-LCD_REMOTE_DEPTH))
82 #define LCD_REMOTE_BLACK LCD_REMOTE_BRIGHTNESS(0)
83 #define LCD_REMOTE_DARKGRAY LCD_REMOTE_BRIGHTNESS(85)
84 #define LCD_REMOTE_LIGHTGRAY LCD_REMOTE_BRIGHTNESS(170)
85 #define LCD_REMOTE_WHITE LCD_REMOTE_BRIGHTNESS(255)
86 #define LCD_REMOTE_DEFAULT_FG LCD_REMOTE_BLACK
87 #define LCD_REMOTE_DEFAULT_BG LCD_REMOTE_WHITE
90 /* Frame buffer dimensions (format checks only cover existing targets!) */
91 #if LCD_REMOTE_DEPTH == 1
92 #define LCD_REMOTE_FBHEIGHT ((LCD_REMOTE_HEIGHT+7)/8)
93 #elif LCD_REMOTE_DEPTH == 2
94 #if LCD_REMOTE_PIXELFORMAT == VERTICAL_INTERLEAVED
95 #define LCD_REMOTE_FBHEIGHT ((LCD_REMOTE_HEIGHT+7)/8)
97 #endif /* LCD_REMOTE_DEPTH */
98 /* Set defaults if not defined different yet. The defaults apply to both
99 * dimensions for LCD_REMOTE_DEPTH >= 8 */
100 #ifndef LCD_REMOTE_FBWIDTH
101 #define LCD_REMOTE_FBWIDTH LCD_REMOTE_WIDTH
103 #ifndef LCD_REMOTE_FBHEIGHT
104 #define LCD_REMOTE_FBHEIGHT LCD_REMOTE_HEIGHT
106 /* The actual framebuffer */
107 extern fb_remote_data lcd_remote_framebuffer
[LCD_REMOTE_FBHEIGHT
][LCD_REMOTE_FBWIDTH
];
110 extern void lcd_remote_init(void);
111 extern int lcd_remote_default_contrast(void);
112 extern void lcd_remote_set_contrast(int val
);
114 extern void lcd_remote_set_viewport(struct viewport
* vp
);
115 extern void lcd_remote_clear_display(void);
116 extern void lcd_remote_clear_viewport(void);
117 extern void lcd_remote_puts(int x
, int y
, const unsigned char *str
);
118 extern void lcd_remote_puts_style(int x
, int y
, const unsigned char *str
,
120 extern void lcd_remote_puts_offset(int x
, int y
, const unsigned char *str
,
122 extern void lcd_remote_puts_style_offset(int x
, int y
, const unsigned char *str
,
123 int style
, int offset
);
124 extern void lcd_remote_putc(int x
, int y
, unsigned short ch
);
125 extern void lcd_remote_stop_scroll(void);
126 extern void lcd_remote_scroll_speed(int speed
);
127 extern void lcd_remote_scroll_delay(int ms
);
128 extern void lcd_remote_puts_scroll(int x
, int y
, const unsigned char *str
);
129 extern void lcd_remote_puts_scroll_style(int x
, int y
, const unsigned char *str
,
131 extern void lcd_remote_puts_scroll_offset(int x
, int y
,
132 const unsigned char *str
, int offset
);
133 extern void lcd_remote_puts_scroll_style_offset(int x
, int y
,
134 const unsigned char *string
,
135 int style
, int offset
);
137 extern void lcd_remote_update(void);
138 extern void lcd_remote_update_rect(int x
, int y
, int width
, int height
);
139 extern void lcd_remote_update_viewport(void);
140 extern void lcd_remote_update_viewport_rect(int x
, int y
, int width
, int height
);
142 extern void lcd_remote_set_invert_display(bool yesno
);
143 extern void lcd_remote_set_flip(bool yesno
);
145 extern void lcd_remote_set_drawmode(int mode
);
146 extern int lcd_remote_get_drawmode(void);
147 extern void lcd_remote_setmargins(int xmargin
, int ymargin
);
148 extern int lcd_remote_getxmargin(void);
149 extern int lcd_remote_getymargin(void);
150 extern int lcd_remote_getwidth(void);
151 extern int lcd_remote_getheight(void);
152 extern void lcd_remote_setfont(int font
);
153 extern int lcd_remote_getfont(void);
154 extern int lcd_remote_getstringsize(const unsigned char *str
, int *w
, int *h
);
156 /* low level drawing function pointer arrays */
157 #if LCD_REMOTE_DEPTH > 1
158 extern lcd_remote_pixelfunc_type
* const *lcd_remote_pixelfuncs
;
159 extern lcd_remote_blockfunc_type
* const *lcd_remote_blockfuncs
;
161 extern lcd_remote_pixelfunc_type
* const lcd_remote_pixelfuncs
[8];
162 extern lcd_remote_blockfunc_type
* const lcd_remote_blockfuncs
[8];
165 extern void lcd_remote_drawpixel(int x
, int y
);
166 extern void lcd_remote_drawline(int x1
, int y1
, int x2
, int y2
);
167 extern void lcd_remote_hline(int x1
, int x2
, int y
);
168 extern void lcd_remote_vline(int x
, int y1
, int y2
);
169 extern void lcd_remote_drawrect(int x
, int y
, int width
, int height
);
170 extern void lcd_remote_fillrect(int x
, int y
, int width
, int height
);
171 extern void lcd_remote_bitmap_part(const fb_remote_data
*src
, int src_x
,
172 int src_y
, int stride
, int x
, int y
,
173 int width
, int height
);
174 extern void lcd_remote_bitmap(const fb_remote_data
*src
, int x
, int y
,
175 int width
, int height
);
176 extern void lcd_remote_putsxy(int x
, int y
, const unsigned char *str
);
178 extern void lcd_remote_bidir_scroll(int threshold
);
179 extern void lcd_remote_scroll_step(int pixels
);
181 #if LCD_REMOTE_DEPTH > 1
182 extern void lcd_remote_set_foreground(unsigned foreground
);
183 extern unsigned lcd_remote_get_foreground(void);
184 extern void lcd_remote_set_background(unsigned background
);
185 extern unsigned lcd_remote_get_background(void);
186 extern void lcd_remote_set_drawinfo(int mode
, unsigned foreground
,
187 unsigned background
);
188 void lcd_remote_set_backdrop(fb_remote_data
* backdrop
);
189 fb_remote_data
* lcd_remote_get_backdrop(void);
191 extern void lcd_remote_mono_bitmap_part(const unsigned char *src
, int src_x
,
192 int src_y
, int stride
, int x
, int y
,
193 int width
, int height
);
194 extern void lcd_remote_mono_bitmap(const unsigned char *src
, int x
, int y
,
195 int width
, int height
);
196 extern void lcd_remote_bitmap_transparent_part(const fb_remote_data
*src
,
197 int src_x
, int src_y
,
198 int stride
, int x
, int y
,
199 int width
, int height
);
200 extern void lcd_bitmap_remote_transparent(const fb_remote_data
*src
, int x
,
201 int y
, int width
, int height
);
202 #else /* LCD_REMOTE_DEPTH == 1 */
203 #define lcd_remote_mono_bitmap lcd_remote_bitmap
204 #define lcd_remote_mono_bitmap_part lcd_remote_bitmap_part
205 #endif /* LCD_REMOTE_DEPTH */
208 #endif /* __LCD_REMOTE_H__ */