Add backdrop functions to the multiscreen api and add a enum backdrop_type parameter...
[kugel-rb.git] / firmware / export / lcd-remote.h
blob01df5a7eab864afba8b5271742df0372503e3c10
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_puts_style(int x, int y, const unsigned char *str,
125 int style);
126 extern void lcd_remote_puts_offset(int x, int y, const unsigned char *str,
127 int offset);
128 extern void lcd_remote_puts_style_offset(int x, int y, const unsigned char *str,
129 int style, int offset);
130 extern void lcd_remote_putc(int x, int y, unsigned short ch);
131 extern void lcd_remote_stop_scroll(void);
132 extern void lcd_remote_scroll_speed(int speed);
133 extern void lcd_remote_scroll_delay(int ms);
134 extern void lcd_remote_puts_scroll(int x, int y, const unsigned char *str);
135 extern void lcd_remote_puts_scroll_style(int x, int y, const unsigned char *str,
136 int style);
137 extern void lcd_remote_puts_scroll_offset(int x, int y,
138 const unsigned char *str, int offset);
139 extern void lcd_remote_puts_scroll_style_offset(int x, int y,
140 const unsigned char *string,
141 int style, int offset);
143 extern void lcd_remote_update(void);
144 extern void lcd_remote_update_rect(int x, int y, int width, int height);
145 extern void lcd_remote_update_viewport(void);
146 extern void lcd_remote_update_viewport_rect(int x, int y, int width, int height);
148 extern void lcd_remote_set_invert_display(bool yesno);
149 extern void lcd_remote_set_flip(bool yesno);
151 extern void lcd_remote_set_drawmode(int mode);
152 extern int lcd_remote_get_drawmode(void);
153 extern int lcd_remote_getwidth(void);
154 extern int lcd_remote_getheight(void);
155 extern void lcd_remote_setfont(int font);
156 extern int lcd_remote_getfont(void);
157 extern int lcd_remote_getstringsize(const unsigned char *str, int *w, int *h);
159 /* low level drawing function pointer arrays */
160 #if LCD_REMOTE_DEPTH > 1
161 extern lcd_remote_pixelfunc_type* const *lcd_remote_pixelfuncs;
162 extern lcd_remote_blockfunc_type* const *lcd_remote_blockfuncs;
163 #else
164 extern lcd_remote_pixelfunc_type* const lcd_remote_pixelfuncs[8];
165 extern lcd_remote_blockfunc_type* const lcd_remote_blockfuncs[8];
166 #endif
168 extern void lcd_remote_drawpixel(int x, int y);
169 extern void lcd_remote_drawline(int x1, int y1, int x2, int y2);
170 extern void lcd_remote_hline(int x1, int x2, int y);
171 extern void lcd_remote_vline(int x, int y1, int y2);
172 extern void lcd_remote_drawrect(int x, int y, int width, int height);
173 extern void lcd_remote_fillrect(int x, int y, int width, int height);
174 extern void lcd_remote_bitmap_part(const fb_remote_data *src, int src_x,
175 int src_y, int stride, int x, int y,
176 int width, int height);
177 extern void lcd_remote_bitmap(const fb_remote_data *src, int x, int y,
178 int width, int height);
179 extern void lcd_remote_putsxy(int x, int y, const unsigned char *str);
181 extern void lcd_remote_bidir_scroll(int threshold);
182 extern void lcd_remote_scroll_step(int pixels);
184 #if LCD_REMOTE_DEPTH > 1
185 extern void lcd_remote_set_foreground(unsigned foreground);
186 extern unsigned lcd_remote_get_foreground(void);
187 extern void lcd_remote_set_background(unsigned background);
188 extern unsigned lcd_remote_get_background(void);
189 extern void lcd_remote_set_drawinfo(int mode, unsigned foreground,
190 unsigned background);
191 void lcd_remote_set_backdrop(fb_remote_data* backdrop);
192 fb_remote_data* lcd_remote_get_backdrop(void);
194 extern void lcd_remote_mono_bitmap_part(const unsigned char *src, int src_x,
195 int src_y, int stride, int x, int y,
196 int width, int height);
197 extern void lcd_remote_mono_bitmap(const unsigned char *src, int x, int y,
198 int width, int height);
199 extern void lcd_remote_bitmap_transparent_part(const fb_remote_data *src,
200 int src_x, int src_y,
201 int stride, int x, int y,
202 int width, int height);
203 extern void lcd_bitmap_remote_transparent(const fb_remote_data *src, int x,
204 int y, int width, int height);
205 #else /* LCD_REMOTE_DEPTH == 1 */
206 #define lcd_remote_mono_bitmap lcd_remote_bitmap
207 #define lcd_remote_mono_bitmap_part lcd_remote_bitmap_part
208 #endif /* LCD_REMOTE_DEPTH */
210 #endif
211 #endif /* __LCD_REMOTE_H__ */