Linus Nielsen Feltzing | a6a0190 | 2005-04-15 09:42:12 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
| 8 | * $Id$ |
| 9 | * |
Nicolas Pennequin | 357ffb3 | 2008-05-05 10:32:46 +0000 | [diff] [blame^] | 10 | * Copyright (C) 2005 by Richard S. La Charité |
Linus Nielsen Feltzing | a6a0190 | 2005-04-15 09:42:12 +0000 | [diff] [blame] | 11 | * |
| 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. |
| 14 | * |
| 15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 16 | * KIND, either express or implied. |
| 17 | * |
| 18 | ****************************************************************************/ |
| 19 | |
| 20 | #ifndef __LCD_REMOTE_H__ |
| 21 | #define __LCD_REMOTE_H__ |
| 22 | |
Linus Nielsen Feltzing | a6a0190 | 2005-04-15 09:42:12 +0000 | [diff] [blame] | 23 | #include <stdbool.h> |
| 24 | #include "cpu.h" |
| 25 | #include "config.h" |
Dave Chapman | 945c8a2 | 2008-01-07 20:34:11 +0000 | [diff] [blame] | 26 | #include "lcd.h" |
Linus Nielsen Feltzing | a6a0190 | 2005-04-15 09:42:12 +0000 | [diff] [blame] | 27 | |
Linus Nielsen Feltzing | 7e01562 | 2005-04-15 12:37:54 +0000 | [diff] [blame] | 28 | #ifdef HAVE_REMOTE_LCD |
Jens Arnold | 6a556c1 | 2005-06-23 16:53:54 +0000 | [diff] [blame] | 29 | |
Dave Chapman | 78d29f5 | 2008-03-26 23:35:34 +0000 | [diff] [blame] | 30 | #if defined(TARGET_TREE) && !defined(__PCTOOL__) |
Jens Arnold | d528e54 | 2007-02-25 22:09:14 +0000 | [diff] [blame] | 31 | #include "lcd-remote-target.h" |
| 32 | #endif |
| 33 | |
Linus Nielsen Feltzing | 0081184 | 2006-02-17 22:38:38 +0000 | [diff] [blame] | 34 | #if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES) |
Hristo Kovachev | 0d58ea4 | 2006-07-28 13:35:36 +0000 | [diff] [blame] | 35 | #define REMOTETYPE_UNPLUGGED 0 |
Linus Nielsen Feltzing | 0081184 | 2006-02-17 22:38:38 +0000 | [diff] [blame] | 36 | #define REMOTETYPE_H100_LCD 1 |
| 37 | #define REMOTETYPE_H300_LCD 2 |
| 38 | #define REMOTETYPE_H300_NONLCD 3 |
Jens Arnold | d528e54 | 2007-02-25 22:09:14 +0000 | [diff] [blame] | 39 | int remote_type(void); |
| 40 | #endif |
| 41 | |
Brandon Low | 74cbb0a | 2007-06-17 21:16:34 +0000 | [diff] [blame] | 42 | #define STYLE_DEFAULT 0x00000000 |
| 43 | #define STYLE_INVERT 0x20000000 |
Jens Arnold | cb36fec | 2006-07-28 07:17:00 +0000 | [diff] [blame] | 44 | |
| 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; |
| 49 | #else |
| 50 | typedef unsigned char fb_remote_data; |
| 51 | #endif |
| 52 | #elif LCD_DEPTH <= 16 |
| 53 | typedef unsigned short fb_remote_data; |
| 54 | #else |
| 55 | typedef unsigned long fb_remote_data; |
| 56 | #endif |
| 57 | |
Jens Arnold | 17bc340 | 2008-03-12 23:08:33 +0000 | [diff] [blame] | 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); |
Jens Arnold | cb36fec | 2006-07-28 07:17:00 +0000 | [diff] [blame] | 63 | |
| 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, |
| 67 | unsigned bits); |
| 68 | |
Michael Sevakis | 6aa12c1 | 2006-10-14 01:32:58 +0000 | [diff] [blame] | 69 | #if LCD_REMOTE_DEPTH > 1 /* greyscale - 8 bit max */ |
| 70 | #ifdef HAVE_LCD_COLOR |
| 71 | extern unsigned lcd_remote_color_to_native(unsigned color); |
| 72 | #endif |
| 73 | |
Jens Arnold | cb36fec | 2006-07-28 07:17:00 +0000 | [diff] [blame] | 74 | #define LCD_REMOTE_MAX_LEVEL ((1 << LCD_REMOTE_DEPTH) - 1) |
Michael Sevakis | 6aa12c1 | 2006-10-14 01:32:58 +0000 | [diff] [blame] | 75 | /** |
| 76 | * On 2 bit for example (y >> (8-DEPTH)) = (y >> 6) = y/64 gives: |
| 77 | * |000-063|064-127|128-191|192-255| |
| 78 | * | 0 | 1 | 2 | 3 | |
| 79 | */ |
| 80 | #define LCD_REMOTE_BRIGHTNESS(y) ((y) >> (8-LCD_REMOTE_DEPTH)) |
Jens Arnold | cb36fec | 2006-07-28 07:17:00 +0000 | [diff] [blame] | 81 | |
| 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 |
Jens Arnold | cb36fec | 2006-07-28 07:17:00 +0000 | [diff] [blame] | 88 | #endif |
| 89 | |
Jens Arnold | 51223e5 | 2007-02-20 19:31:34 +0000 | [diff] [blame] | 90 | /* Frame buffer dimensions (format checks only cover existing targets!) */ |
Jens Arnold | cb36fec | 2006-07-28 07:17:00 +0000 | [diff] [blame] | 91 | #if LCD_REMOTE_DEPTH == 1 |
Jens Arnold | 51223e5 | 2007-02-20 19:31:34 +0000 | [diff] [blame] | 92 | #define LCD_REMOTE_FBHEIGHT ((LCD_REMOTE_HEIGHT+7)/8) |
Jens Arnold | cb36fec | 2006-07-28 07:17:00 +0000 | [diff] [blame] | 93 | #elif LCD_REMOTE_DEPTH == 2 |
| 94 | #if LCD_REMOTE_PIXELFORMAT == VERTICAL_INTERLEAVED |
Jens Arnold | 51223e5 | 2007-02-20 19:31:34 +0000 | [diff] [blame] | 95 | #define LCD_REMOTE_FBHEIGHT ((LCD_REMOTE_HEIGHT+7)/8) |
Jens Arnold | cb36fec | 2006-07-28 07:17:00 +0000 | [diff] [blame] | 96 | #endif |
Jens Arnold | 51223e5 | 2007-02-20 19:31:34 +0000 | [diff] [blame] | 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 |
Jens Arnold | cb36fec | 2006-07-28 07:17:00 +0000 | [diff] [blame] | 102 | #endif |
Jens Arnold | 51223e5 | 2007-02-20 19:31:34 +0000 | [diff] [blame] | 103 | #ifndef LCD_REMOTE_FBHEIGHT |
| 104 | #define LCD_REMOTE_FBHEIGHT LCD_REMOTE_HEIGHT |
| 105 | #endif |
| 106 | /* The actual framebuffer */ |
| 107 | extern fb_remote_data lcd_remote_framebuffer[LCD_REMOTE_FBHEIGHT][LCD_REMOTE_FBWIDTH]; |
| 108 | |
Jens Arnold | cb36fec | 2006-07-28 07:17:00 +0000 | [diff] [blame] | 109 | |
Linus Nielsen Feltzing | a6a0190 | 2005-04-15 09:42:12 +0000 | [diff] [blame] | 110 | extern void lcd_remote_init(void); |
Christian Gmeiner | 394c2d9 | 2005-04-15 12:36:03 +0000 | [diff] [blame] | 111 | extern int lcd_remote_default_contrast(void); |
Jens Arnold | 6a556c1 | 2005-06-23 16:53:54 +0000 | [diff] [blame] | 112 | extern void lcd_remote_set_contrast(int val); |
| 113 | |
Dave Chapman | 945c8a2 | 2008-01-07 20:34:11 +0000 | [diff] [blame] | 114 | extern void lcd_remote_set_viewport(struct viewport* vp); |
Jens Arnold | 6a556c1 | 2005-06-23 16:53:54 +0000 | [diff] [blame] | 115 | extern void lcd_remote_clear_display(void); |
Dave Chapman | 945c8a2 | 2008-01-07 20:34:11 +0000 | [diff] [blame] | 116 | extern void lcd_remote_clear_viewport(void); |
Jens Arnold | cb36fec | 2006-07-28 07:17:00 +0000 | [diff] [blame] | 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, |
Brandon Low | d3a03b6 | 2006-01-22 04:24:26 +0000 | [diff] [blame] | 119 | int style); |
Michael Sevakis | 6aa12c1 | 2006-10-14 01:32:58 +0000 | [diff] [blame] | 120 | extern void lcd_remote_puts_offset(int x, int y, const unsigned char *str, |
Jens Arnold | cb36fec | 2006-07-28 07:17:00 +0000 | [diff] [blame] | 121 | int offset); |
| 122 | extern void lcd_remote_puts_style_offset(int x, int y, const unsigned char *str, |
| 123 | int style, int offset); |
Christian Gmeiner | 7d98481 | 2005-04-25 23:47:51 +0000 | [diff] [blame] | 124 | extern void lcd_remote_putc(int x, int y, unsigned short ch); |
Jens Arnold | 6a556c1 | 2005-06-23 16:53:54 +0000 | [diff] [blame] | 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); |
Jens Arnold | cb36fec | 2006-07-28 07:17:00 +0000 | [diff] [blame] | 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, |
| 130 | int style); |
| 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, |
Tomas Salfischberger | 7fa39df | 2006-01-22 01:42:05 +0000 | [diff] [blame] | 135 | int style, int offset); |
| 136 | |
Jens Arnold | 6a556c1 | 2005-06-23 16:53:54 +0000 | [diff] [blame] | 137 | extern void lcd_remote_update(void); |
Jens Arnold | 576908d | 2005-06-29 01:39:50 +0000 | [diff] [blame] | 138 | extern void lcd_remote_update_rect(int x, int y, int width, int height); |
Dave Chapman | 945c8a2 | 2008-01-07 20:34:11 +0000 | [diff] [blame] | 139 | extern void lcd_remote_update_viewport(void); |
| 140 | extern void lcd_remote_update_viewport_rect(int x, int y, int width, int height); |
Christian Gmeiner | 7d98481 | 2005-04-25 23:47:51 +0000 | [diff] [blame] | 141 | |
Jens Arnold | 6a556c1 | 2005-06-23 16:53:54 +0000 | [diff] [blame] | 142 | extern void lcd_remote_set_invert_display(bool yesno); |
| 143 | extern void lcd_remote_set_flip(bool yesno); |
Jens Arnold | 576908d | 2005-06-29 01:39:50 +0000 | [diff] [blame] | 144 | |
| 145 | extern void lcd_remote_set_drawmode(int mode); |
| 146 | extern int lcd_remote_get_drawmode(void); |
Christian Gmeiner | 7d98481 | 2005-04-25 23:47:51 +0000 | [diff] [blame] | 147 | extern void lcd_remote_setmargins(int xmargin, int ymargin); |
| 148 | extern int lcd_remote_getxmargin(void); |
| 149 | extern int lcd_remote_getymargin(void); |
Dave Chapman | 945c8a2 | 2008-01-07 20:34:11 +0000 | [diff] [blame] | 150 | extern int lcd_remote_getwidth(void); |
| 151 | extern int lcd_remote_getheight(void); |
Jens Arnold | 6a556c1 | 2005-06-23 16:53:54 +0000 | [diff] [blame] | 152 | extern void lcd_remote_setfont(int font); |
Dave Chapman | 3646c31 | 2008-01-08 01:22:14 +0000 | [diff] [blame] | 153 | extern int lcd_remote_getfont(void); |
Jens Arnold | 6a556c1 | 2005-06-23 16:53:54 +0000 | [diff] [blame] | 154 | extern int lcd_remote_getstringsize(const unsigned char *str, int *w, int *h); |
Jens Arnold | 576908d | 2005-06-29 01:39:50 +0000 | [diff] [blame] | 155 | |
Jens Arnold | cb36fec | 2006-07-28 07:17:00 +0000 | [diff] [blame] | 156 | /* low level drawing function pointer arrays */ |
Jens Arnold | 11e2e56 | 2006-11-26 14:26:08 +0000 | [diff] [blame] | 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; |
| 160 | #else |
Jens Arnold | cb36fec | 2006-07-28 07:17:00 +0000 | [diff] [blame] | 161 | extern lcd_remote_pixelfunc_type* const lcd_remote_pixelfuncs[8]; |
| 162 | extern lcd_remote_blockfunc_type* const lcd_remote_blockfuncs[8]; |
Jens Arnold | 11e2e56 | 2006-11-26 14:26:08 +0000 | [diff] [blame] | 163 | #endif |
Jens Arnold | cb36fec | 2006-07-28 07:17:00 +0000 | [diff] [blame] | 164 | |
Christian Gmeiner | 7d98481 | 2005-04-25 23:47:51 +0000 | [diff] [blame] | 165 | extern void lcd_remote_drawpixel(int x, int y); |
Jens Arnold | 6a556c1 | 2005-06-23 16:53:54 +0000 | [diff] [blame] | 166 | extern void lcd_remote_drawline(int x1, int y1, int x2, int y2); |
Jens Arnold | 576908d | 2005-06-29 01:39:50 +0000 | [diff] [blame] | 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); |
Jens Arnold | cb36fec | 2006-07-28 07:17:00 +0000 | [diff] [blame] | 171 | extern void lcd_remote_bitmap_part(const fb_remote_data *src, int src_x, |
Jens Arnold | 576908d | 2005-06-29 01:39:50 +0000 | [diff] [blame] | 172 | int src_y, int stride, int x, int y, |
| 173 | int width, int height); |
Jens Arnold | cb36fec | 2006-07-28 07:17:00 +0000 | [diff] [blame] | 174 | extern void lcd_remote_bitmap(const fb_remote_data *src, int x, int y, |
Jens Arnold | 576908d | 2005-06-29 01:39:50 +0000 | [diff] [blame] | 175 | int width, int height); |
Jens Arnold | cb36fec | 2006-07-28 07:17:00 +0000 | [diff] [blame] | 176 | extern void lcd_remote_putsxy(int x, int y, const unsigned char *str); |
Jens Arnold | 576908d | 2005-06-29 01:39:50 +0000 | [diff] [blame] | 177 | |
Christian Gmeiner | 7d98481 | 2005-04-25 23:47:51 +0000 | [diff] [blame] | 178 | extern void lcd_remote_bidir_scroll(int threshold); |
| 179 | extern void lcd_remote_scroll_step(int pixels); |
Linus Nielsen Feltzing | a6a0190 | 2005-04-15 09:42:12 +0000 | [diff] [blame] | 180 | |
Jens Arnold | cb36fec | 2006-07-28 07:17:00 +0000 | [diff] [blame] | 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); |
Nicolas Pennequin | 7fdfa56 | 2007-04-25 21:44:56 +0000 | [diff] [blame] | 188 | void lcd_remote_set_backdrop(fb_remote_data* backdrop); |
| 189 | fb_remote_data* lcd_remote_get_backdrop(void); |
Jens Arnold | cb36fec | 2006-07-28 07:17:00 +0000 | [diff] [blame] | 190 | |
| 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 */ |
Jens Arnold | d7f9439 | 2005-07-07 00:05:29 +0000 | [diff] [blame] | 203 | #define lcd_remote_mono_bitmap lcd_remote_bitmap |
| 204 | #define lcd_remote_mono_bitmap_part lcd_remote_bitmap_part |
Jens Arnold | cb36fec | 2006-07-28 07:17:00 +0000 | [diff] [blame] | 205 | #endif /* LCD_REMOTE_DEPTH */ |
Jens Arnold | d7f9439 | 2005-07-07 00:05:29 +0000 | [diff] [blame] | 206 | |
Linus Nielsen Feltzing | a6a0190 | 2005-04-15 09:42:12 +0000 | [diff] [blame] | 207 | #endif |
Jens Arnold | cb36fec | 2006-07-28 07:17:00 +0000 | [diff] [blame] | 208 | #endif /* __LCD_REMOTE_H__ */ |