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
;
53 typedef unsigned char fb_remote_data
;
57 typedef unsigned short fb_remote_data
;
60 typedef unsigned long fb_remote_data
;
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
,
75 #if LCD_REMOTE_DEPTH > 1 /* greyscale - 8 bit max */
77 extern unsigned lcd_remote_color_to_native(unsigned color
);
80 #define LCD_REMOTE_MAX_LEVEL ((1 << LCD_REMOTE_DEPTH) - 1)
82 * On 2 bit for example (y >> (8-DEPTH)) = (y >> 6) = y/64 gives:
83 * |000-063|064-127|128-191|192-255|
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
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)
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
109 #ifndef LCD_REMOTE_FBHEIGHT
110 #define LCD_REMOTE_FBHEIGHT LCD_REMOTE_HEIGHT
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
,
127 extern void lcd_remote_puts_offset(int x
, int y
, const unsigned char *str
,
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_putc(int x
, int y
, unsigned short ch
);
132 extern void lcd_remote_stop_scroll(void);
133 extern void lcd_remote_scroll_speed(int speed
);
134 extern void lcd_remote_scroll_delay(int ms
);
135 extern void lcd_remote_puts_scroll(int x
, int y
, const unsigned char *str
);
136 extern void lcd_remote_puts_scroll_style(int x
, int y
, const unsigned char *str
,
138 extern void lcd_remote_puts_scroll_offset(int x
, int y
,
139 const unsigned char *str
, int offset
);
140 extern void lcd_remote_puts_scroll_style_offset(int x
, int y
,
141 const unsigned char *string
,
142 int style
, int offset
);
144 extern void lcd_remote_update(void);
145 extern void lcd_remote_update_rect(int x
, int y
, int width
, int height
);
146 extern void lcd_remote_update_viewport(void);
147 extern void lcd_remote_update_viewport_rect(int x
, int y
, int width
, int height
);
149 extern void lcd_remote_set_invert_display(bool yesno
);
150 extern void lcd_remote_set_flip(bool yesno
);
152 extern void lcd_remote_set_drawmode(int mode
);
153 extern int lcd_remote_get_drawmode(void);
154 extern int lcd_remote_getwidth(void);
155 extern int lcd_remote_getheight(void);
156 extern void lcd_remote_setfont(int font
);
157 extern int lcd_remote_getfont(void);
158 extern int lcd_remote_getstringsize(const unsigned char *str
, int *w
, int *h
);
160 /* low level drawing function pointer arrays */
161 #if LCD_REMOTE_DEPTH > 1
162 extern lcd_remote_pixelfunc_type
* const *lcd_remote_pixelfuncs
;
163 extern lcd_remote_blockfunc_type
* const *lcd_remote_blockfuncs
;
165 extern lcd_remote_pixelfunc_type
* const lcd_remote_pixelfuncs
[8];
166 extern lcd_remote_blockfunc_type
* const lcd_remote_blockfuncs
[8];
169 extern void lcd_remote_drawpixel(int x
, int y
);
170 extern void lcd_remote_drawline(int x1
, int y1
, int x2
, int y2
);
171 extern void lcd_remote_hline(int x1
, int x2
, int y
);
172 extern void lcd_remote_vline(int x
, int y1
, int y2
);
173 extern void lcd_remote_drawrect(int x
, int y
, int width
, int height
);
174 extern void lcd_remote_fillrect(int x
, int y
, int width
, int height
);
175 extern void lcd_remote_bitmap_part(const fb_remote_data
*src
, int src_x
,
176 int src_y
, int stride
, int x
, int y
,
177 int width
, int height
);
178 extern void lcd_remote_bitmap(const fb_remote_data
*src
, int x
, int y
,
179 int width
, int height
);
180 extern void lcd_remote_putsxy(int x
, int y
, const unsigned char *str
);
182 extern void lcd_remote_bidir_scroll(int threshold
);
183 extern void lcd_remote_scroll_step(int pixels
);
185 #if LCD_REMOTE_DEPTH > 1
186 extern void lcd_remote_set_foreground(unsigned foreground
);
187 extern unsigned lcd_remote_get_foreground(void);
188 extern void lcd_remote_set_background(unsigned background
);
189 extern unsigned lcd_remote_get_background(void);
190 extern void lcd_remote_set_drawinfo(int mode
, unsigned foreground
,
191 unsigned background
);
192 void lcd_remote_set_backdrop(fb_remote_data
* backdrop
);
193 fb_remote_data
* lcd_remote_get_backdrop(void);
195 extern void lcd_remote_mono_bitmap_part(const unsigned char *src
, int src_x
,
196 int src_y
, int stride
, int x
, int y
,
197 int width
, int height
);
198 extern void lcd_remote_mono_bitmap(const unsigned char *src
, int x
, int y
,
199 int width
, int height
);
200 extern void lcd_remote_bitmap_transparent_part(const fb_remote_data
*src
,
201 int src_x
, int src_y
,
202 int stride
, int x
, int y
,
203 int width
, int height
);
204 extern void lcd_bitmap_remote_transparent(const fb_remote_data
*src
, int x
,
205 int y
, int width
, int height
);
206 #else /* LCD_REMOTE_DEPTH == 1 */
207 #define lcd_remote_mono_bitmap lcd_remote_bitmap
208 #define lcd_remote_mono_bitmap_part lcd_remote_bitmap_part
209 #endif /* LCD_REMOTE_DEPTH */
212 #endif /* __LCD_REMOTE_H__ */