1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
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__
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);
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
;
49 typedef unsigned char fb_remote_data
;
53 typedef unsigned short fb_remote_data
;
56 typedef unsigned long fb_remote_data
;
60 #if LCD_REMOTE_DEPTH > 1 /* greyscale - 8 bit max */
62 extern unsigned lcd_remote_color_to_native(unsigned color
);
65 #define LCD_REMOTE_MAX_LEVEL ((1 << LCD_REMOTE_DEPTH) - 1)
67 * On 2 bit for example (y >> (8-DEPTH)) = (y >> 6) = y/64 gives:
68 * |000-063|064-127|128-191|192-255|
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
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)
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
94 #ifndef LCD_REMOTE_FBHEIGHT
95 #define LCD_REMOTE_FBHEIGHT LCD_REMOTE_HEIGHT
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
);
136 extern void lcd_remote_bitmap_part(const fb_remote_data
*src
, int src_x
,
137 int src_y
, int stride
, int x
, int y
,
138 int width
, int height
);
139 extern void lcd_remote_bitmap(const fb_remote_data
*src
, int x
, int y
,
140 int width
, int height
);
142 /* Low-level drawing function types */
143 typedef void lcd_remote_pixelfunc_type(int x
, int y
);
144 typedef void lcd_remote_blockfunc_type(fb_remote_data
*address
, unsigned mask
,
147 /* low level drawing function pointer arrays */
148 #if LCD_REMOTE_DEPTH > 1
149 extern lcd_remote_pixelfunc_type
* const *lcd_remote_pixelfuncs
;
150 extern lcd_remote_blockfunc_type
* const *lcd_remote_blockfuncs
;
152 extern lcd_remote_pixelfunc_type
* const lcd_remote_pixelfuncs
[8];
153 extern lcd_remote_blockfunc_type
* const lcd_remote_blockfuncs
[8];
156 #endif /* HAVE_LCD_REMOTE */
158 #ifdef HAVE_REMOTE_LCD_TICKING
159 void lcd_remote_emireduce(bool state
);
162 void lcd_remote_init_device(void);
163 void lcd_remote_on(void);
164 void lcd_remote_off(void);
166 extern bool remote_initialized
;
167 bool remote_detect(void);
169 extern void lcd_remote_init(void);
170 extern int lcd_remote_default_contrast(void);
171 extern void lcd_remote_set_contrast(int val
);
173 extern void lcd_remote_set_viewport(struct viewport
* vp
);
174 extern void lcd_remote_clear_display(void);
175 extern void lcd_remote_clear_viewport(void);
176 extern void lcd_remote_puts(int x
, int y
, const unsigned char *str
);
177 extern void lcd_remote_putsf(int x
, int y
, const unsigned char *fmt
, ...);
178 extern void lcd_remote_puts_style(int x
, int y
, const unsigned char *str
,
180 extern void lcd_remote_puts_offset(int x
, int y
, const unsigned char *str
,
182 extern void lcd_remote_puts_style_offset(int x
, int y
, const unsigned char *str
,
183 int style
, int offset
);
184 extern void lcd_remote_puts_style_xyoffset(int x
, int y
, const unsigned char *str
,
185 int style
, int x_offset
, int y_offset
);
186 extern void lcd_remote_putc(int x
, int y
, unsigned short ch
);
187 extern void lcd_remote_stop_scroll(void);
188 extern void lcd_remote_scroll_speed(int speed
);
189 extern void lcd_remote_scroll_delay(int ms
);
190 extern void lcd_remote_puts_scroll(int x
, int y
, const unsigned char *str
);
191 extern void lcd_remote_puts_scroll_style(int x
, int y
, const unsigned char *str
,
193 extern void lcd_remote_puts_scroll_offset(int x
, int y
,
194 const unsigned char *str
, int offset
);
195 extern void lcd_remote_puts_scroll_style_offset(int x
, int y
,
196 const unsigned char *string
,
197 int style
, int offset
);
198 extern void lcd_remote_puts_scroll_style_xyoffset(int x
, int y
,
199 const unsigned char *string
,
200 int style
, int x_offset
,
203 extern void lcd_remote_update(void);
204 extern void lcd_remote_update_rect(int x
, int y
, int width
, int height
);
205 extern void lcd_remote_update_viewport(void);
206 extern void lcd_remote_update_viewport_rect(int x
, int y
, int width
, int height
);
208 extern void lcd_remote_set_invert_display(bool yesno
);
209 extern void lcd_remote_set_flip(bool yesno
);
211 extern void lcd_remote_set_drawmode(int mode
);
212 extern int lcd_remote_get_drawmode(void);
213 extern int lcd_remote_getwidth(void);
214 extern int lcd_remote_getheight(void);
215 extern void lcd_remote_setfont(int font
);
216 extern int lcd_remote_getfont(void);
217 extern int lcd_remote_getstringsize(const unsigned char *str
, int *w
, int *h
);
219 extern void lcd_remote_drawpixel(int x
, int y
);
220 extern void lcd_remote_drawline(int x1
, int y1
, int x2
, int y2
);
221 extern void lcd_remote_hline(int x1
, int x2
, int y
);
222 extern void lcd_remote_vline(int x
, int y1
, int y2
);
223 extern void lcd_remote_drawrect(int x
, int y
, int width
, int height
);
224 extern void lcd_remote_fillrect(int x
, int y
, int width
, int height
);
225 extern void lcd_remote_draw_border_viewport(void);
226 extern void lcd_remote_fill_viewport(void);
227 extern void lcd_remote_putsxy(int x
, int y
, const unsigned char *str
);
228 extern void lcd_remote_putsxyf(int x
, int y
, const unsigned char *fmt
, ...);
230 extern void lcd_remote_bidir_scroll(int threshold
);
231 extern void lcd_remote_scroll_step(int pixels
);
233 extern void lcd_remote_bmp_part(const struct bitmap
* bm
, int src_x
, int src_y
,
234 int x
, int y
, int width
, int height
);
235 extern void lcd_remote_bmp(const struct bitmap
* bm
, int x
, int y
);
237 #endif /* __LCD_REMOTE_H__ */