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
32 #if defined(TARGET_TREE) && !defined(__PCTOOL__)
33 #include "lcd-remote-target.h"
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);
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
;
52 typedef unsigned char fb_remote_data
;
55 typedef unsigned short fb_remote_data
;
57 typedef unsigned long fb_remote_data
;
60 /* common functions */
61 void lcd_remote_init(void);
62 void lcd_remote_write_command(int cmd
);
63 void lcd_remote_write_command_ex(int cmd
, int data
);
64 void lcd_remote_write_data(const fb_remote_data
*data
, int count
);
66 /* Low-level drawing function types */
67 typedef void lcd_remote_pixelfunc_type(int x
, int y
);
68 typedef void lcd_remote_blockfunc_type(fb_remote_data
*address
, unsigned mask
,
71 #if LCD_REMOTE_DEPTH > 1 /* greyscale - 8 bit max */
73 extern unsigned lcd_remote_color_to_native(unsigned color
);
76 #define LCD_REMOTE_MAX_LEVEL ((1 << LCD_REMOTE_DEPTH) - 1)
78 * On 2 bit for example (y >> (8-DEPTH)) = (y >> 6) = y/64 gives:
79 * |000-063|064-127|128-191|192-255|
82 #define LCD_REMOTE_BRIGHTNESS(y) ((y) >> (8-LCD_REMOTE_DEPTH))
84 #define LCD_REMOTE_BLACK LCD_REMOTE_BRIGHTNESS(0)
85 #define LCD_REMOTE_DARKGRAY LCD_REMOTE_BRIGHTNESS(85)
86 #define LCD_REMOTE_LIGHTGRAY LCD_REMOTE_BRIGHTNESS(170)
87 #define LCD_REMOTE_WHITE LCD_REMOTE_BRIGHTNESS(255)
88 #define LCD_REMOTE_DEFAULT_FG LCD_REMOTE_BLACK
89 #define LCD_REMOTE_DEFAULT_BG LCD_REMOTE_WHITE
92 /* Frame buffer dimensions (format checks only cover existing targets!) */
93 #if LCD_REMOTE_DEPTH == 1
94 #define LCD_REMOTE_FBHEIGHT ((LCD_REMOTE_HEIGHT+7)/8)
95 #elif LCD_REMOTE_DEPTH == 2
96 #if LCD_REMOTE_PIXELFORMAT == VERTICAL_INTERLEAVED
97 #define LCD_REMOTE_FBHEIGHT ((LCD_REMOTE_HEIGHT+7)/8)
99 #endif /* LCD_REMOTE_DEPTH */
100 /* Set defaults if not defined different yet. The defaults apply to both
101 * dimensions for LCD_REMOTE_DEPTH >= 8 */
102 #ifndef LCD_REMOTE_FBWIDTH
103 #define LCD_REMOTE_FBWIDTH LCD_REMOTE_WIDTH
105 #ifndef LCD_REMOTE_FBHEIGHT
106 #define LCD_REMOTE_FBHEIGHT LCD_REMOTE_HEIGHT
108 /* The actual framebuffer */
109 extern fb_remote_data lcd_remote_framebuffer
[LCD_REMOTE_FBHEIGHT
][LCD_REMOTE_FBWIDTH
];
112 extern void lcd_remote_init(void);
113 extern int lcd_remote_default_contrast(void);
114 extern void lcd_remote_set_contrast(int val
);
116 extern void lcd_remote_set_viewport(struct viewport
* vp
);
117 extern void lcd_remote_clear_display(void);
118 extern void lcd_remote_clear_viewport(void);
119 extern void lcd_remote_puts(int x
, int y
, const unsigned char *str
);
120 extern void lcd_remote_puts_style(int x
, int y
, const unsigned char *str
,
122 extern void lcd_remote_puts_offset(int x
, int y
, const unsigned char *str
,
124 extern void lcd_remote_puts_style_offset(int x
, int y
, const unsigned char *str
,
125 int style
, int offset
);
126 extern void lcd_remote_putc(int x
, int y
, unsigned short ch
);
127 extern void lcd_remote_stop_scroll(void);
128 extern void lcd_remote_scroll_speed(int speed
);
129 extern void lcd_remote_scroll_delay(int ms
);
130 extern void lcd_remote_puts_scroll(int x
, int y
, const unsigned char *str
);
131 extern void lcd_remote_puts_scroll_style(int x
, int y
, const unsigned char *str
,
133 extern void lcd_remote_puts_scroll_offset(int x
, int y
,
134 const unsigned char *str
, int offset
);
135 extern void lcd_remote_puts_scroll_style_offset(int x
, int y
,
136 const unsigned char *string
,
137 int style
, int offset
);
139 extern void lcd_remote_update(void);
140 extern void lcd_remote_update_rect(int x
, int y
, int width
, int height
);
141 extern void lcd_remote_update_viewport(void);
142 extern void lcd_remote_update_viewport_rect(int x
, int y
, int width
, int height
);
144 extern void lcd_remote_set_invert_display(bool yesno
);
145 extern void lcd_remote_set_flip(bool yesno
);
147 extern void lcd_remote_set_drawmode(int mode
);
148 extern int lcd_remote_get_drawmode(void);
149 extern int lcd_remote_getwidth(void);
150 extern int lcd_remote_getheight(void);
151 extern void lcd_remote_setfont(int font
);
152 extern int lcd_remote_getfont(void);
153 extern int lcd_remote_getstringsize(const unsigned char *str
, int *w
, int *h
);
155 /* low level drawing function pointer arrays */
156 #if LCD_REMOTE_DEPTH > 1
157 extern lcd_remote_pixelfunc_type
* const *lcd_remote_pixelfuncs
;
158 extern lcd_remote_blockfunc_type
* const *lcd_remote_blockfuncs
;
160 extern lcd_remote_pixelfunc_type
* const lcd_remote_pixelfuncs
[8];
161 extern lcd_remote_blockfunc_type
* const lcd_remote_blockfuncs
[8];
164 extern void lcd_remote_drawpixel(int x
, int y
);
165 extern void lcd_remote_drawline(int x1
, int y1
, int x2
, int y2
);
166 extern void lcd_remote_hline(int x1
, int x2
, int y
);
167 extern void lcd_remote_vline(int x
, int y1
, int y2
);
168 extern void lcd_remote_drawrect(int x
, int y
, int width
, int height
);
169 extern void lcd_remote_fillrect(int x
, int y
, int width
, int height
);
170 extern void lcd_remote_bitmap_part(const fb_remote_data
*src
, int src_x
,
171 int src_y
, int stride
, int x
, int y
,
172 int width
, int height
);
173 extern void lcd_remote_bitmap(const fb_remote_data
*src
, int x
, int y
,
174 int width
, int height
);
175 extern void lcd_remote_putsxy(int x
, int y
, const unsigned char *str
);
177 extern void lcd_remote_bidir_scroll(int threshold
);
178 extern void lcd_remote_scroll_step(int pixels
);
180 #if LCD_REMOTE_DEPTH > 1
181 extern void lcd_remote_set_foreground(unsigned foreground
);
182 extern unsigned lcd_remote_get_foreground(void);
183 extern void lcd_remote_set_background(unsigned background
);
184 extern unsigned lcd_remote_get_background(void);
185 extern void lcd_remote_set_drawinfo(int mode
, unsigned foreground
,
186 unsigned background
);
187 void lcd_remote_set_backdrop(fb_remote_data
* backdrop
);
188 fb_remote_data
* lcd_remote_get_backdrop(void);
190 extern void lcd_remote_mono_bitmap_part(const unsigned char *src
, int src_x
,
191 int src_y
, int stride
, int x
, int y
,
192 int width
, int height
);
193 extern void lcd_remote_mono_bitmap(const unsigned char *src
, int x
, int y
,
194 int width
, int height
);
195 extern void lcd_remote_bitmap_transparent_part(const fb_remote_data
*src
,
196 int src_x
, int src_y
,
197 int stride
, int x
, int y
,
198 int width
, int height
);
199 extern void lcd_bitmap_remote_transparent(const fb_remote_data
*src
, int x
,
200 int y
, int width
, int height
);
201 #else /* LCD_REMOTE_DEPTH == 1 */
202 #define lcd_remote_mono_bitmap lcd_remote_bitmap
203 #define lcd_remote_mono_bitmap_part lcd_remote_bitmap_part
204 #endif /* LCD_REMOTE_DEPTH */
207 #endif /* __LCD_REMOTE_H__ */