blob: bccc1e4b29676311daaa63659410fb69b0ae63ef [file] [log] [blame]
Linus Nielsen Feltzinga6a01902005-04-15 09:42:12 +00001/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
Nicolas Pennequin357ffb32008-05-05 10:32:46 +000010 * Copyright (C) 2005 by Richard S. La Charité
Linus Nielsen Feltzinga6a01902005-04-15 09:42:12 +000011 *
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 Feltzinga6a01902005-04-15 09:42:12 +000023#include <stdbool.h>
24#include "cpu.h"
25#include "config.h"
Dave Chapman945c8a22008-01-07 20:34:11 +000026#include "lcd.h"
Linus Nielsen Feltzinga6a01902005-04-15 09:42:12 +000027
Linus Nielsen Feltzing7e015622005-04-15 12:37:54 +000028#ifdef HAVE_REMOTE_LCD
Jens Arnold6a556c12005-06-23 16:53:54 +000029
Dave Chapman78d29f52008-03-26 23:35:34 +000030#if defined(TARGET_TREE) && !defined(__PCTOOL__)
Jens Arnoldd528e542007-02-25 22:09:14 +000031#include "lcd-remote-target.h"
32#endif
33
Linus Nielsen Feltzing00811842006-02-17 22:38:38 +000034#if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
Hristo Kovachev0d58ea42006-07-28 13:35:36 +000035#define REMOTETYPE_UNPLUGGED 0
Linus Nielsen Feltzing00811842006-02-17 22:38:38 +000036#define REMOTETYPE_H100_LCD 1
37#define REMOTETYPE_H300_LCD 2
38#define REMOTETYPE_H300_NONLCD 3
Jens Arnoldd528e542007-02-25 22:09:14 +000039int remote_type(void);
40#endif
41
Brandon Low74cbb0a2007-06-17 21:16:34 +000042#define STYLE_DEFAULT 0x00000000
43#define STYLE_INVERT 0x20000000
Jens Arnoldcb36fec2006-07-28 07:17:00 +000044
45#if LCD_REMOTE_DEPTH <= 8
46#if (LCD_REMOTE_PIXELFORMAT == VERTICAL_INTERLEAVED) \
47 || (LCD_REMOTE_PIXELFORMAT == HORIZONTAL_INTERLEAVED)
48typedef unsigned short fb_remote_data;
49#else
50typedef unsigned char fb_remote_data;
51#endif
52#elif LCD_DEPTH <= 16
53typedef unsigned short fb_remote_data;
54#else
55typedef unsigned long fb_remote_data;
56#endif
57
Jens Arnold17bc3402008-03-12 23:08:33 +000058/* common functions */
59void lcd_remote_init(void);
60void lcd_remote_write_command(int cmd);
61void lcd_remote_write_command_ex(int cmd, int data);
62void lcd_remote_write_data(const fb_remote_data *data, int count);
Jens Arnoldcb36fec2006-07-28 07:17:00 +000063
64/* Low-level drawing function types */
65typedef void lcd_remote_pixelfunc_type(int x, int y);
66typedef void lcd_remote_blockfunc_type(fb_remote_data *address, unsigned mask,
67 unsigned bits);
68
Michael Sevakis6aa12c12006-10-14 01:32:58 +000069#if LCD_REMOTE_DEPTH > 1 /* greyscale - 8 bit max */
70#ifdef HAVE_LCD_COLOR
71extern unsigned lcd_remote_color_to_native(unsigned color);
72#endif
73
Jens Arnoldcb36fec2006-07-28 07:17:00 +000074#define LCD_REMOTE_MAX_LEVEL ((1 << LCD_REMOTE_DEPTH) - 1)
Michael Sevakis6aa12c12006-10-14 01:32:58 +000075/**
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 Arnoldcb36fec2006-07-28 07:17:00 +000081
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 Arnoldcb36fec2006-07-28 07:17:00 +000088#endif
89
Jens Arnold51223e52007-02-20 19:31:34 +000090/* Frame buffer dimensions (format checks only cover existing targets!) */
Jens Arnoldcb36fec2006-07-28 07:17:00 +000091#if LCD_REMOTE_DEPTH == 1
Jens Arnold51223e52007-02-20 19:31:34 +000092#define LCD_REMOTE_FBHEIGHT ((LCD_REMOTE_HEIGHT+7)/8)
Jens Arnoldcb36fec2006-07-28 07:17:00 +000093#elif LCD_REMOTE_DEPTH == 2
94#if LCD_REMOTE_PIXELFORMAT == VERTICAL_INTERLEAVED
Jens Arnold51223e52007-02-20 19:31:34 +000095#define LCD_REMOTE_FBHEIGHT ((LCD_REMOTE_HEIGHT+7)/8)
Jens Arnoldcb36fec2006-07-28 07:17:00 +000096#endif
Jens Arnold51223e52007-02-20 19:31:34 +000097#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 Arnoldcb36fec2006-07-28 07:17:00 +0000102#endif
Jens Arnold51223e52007-02-20 19:31:34 +0000103#ifndef LCD_REMOTE_FBHEIGHT
104#define LCD_REMOTE_FBHEIGHT LCD_REMOTE_HEIGHT
105#endif
106/* The actual framebuffer */
107extern fb_remote_data lcd_remote_framebuffer[LCD_REMOTE_FBHEIGHT][LCD_REMOTE_FBWIDTH];
108
Jens Arnoldcb36fec2006-07-28 07:17:00 +0000109
Linus Nielsen Feltzinga6a01902005-04-15 09:42:12 +0000110extern void lcd_remote_init(void);
Christian Gmeiner394c2d92005-04-15 12:36:03 +0000111extern int lcd_remote_default_contrast(void);
Jens Arnold6a556c12005-06-23 16:53:54 +0000112extern void lcd_remote_set_contrast(int val);
113
Dave Chapman945c8a22008-01-07 20:34:11 +0000114extern void lcd_remote_set_viewport(struct viewport* vp);
Jens Arnold6a556c12005-06-23 16:53:54 +0000115extern void lcd_remote_clear_display(void);
Dave Chapman945c8a22008-01-07 20:34:11 +0000116extern void lcd_remote_clear_viewport(void);
Jens Arnoldcb36fec2006-07-28 07:17:00 +0000117extern void lcd_remote_puts(int x, int y, const unsigned char *str);
118extern void lcd_remote_puts_style(int x, int y, const unsigned char *str,
Brandon Lowd3a03b62006-01-22 04:24:26 +0000119 int style);
Michael Sevakis6aa12c12006-10-14 01:32:58 +0000120extern void lcd_remote_puts_offset(int x, int y, const unsigned char *str,
Jens Arnoldcb36fec2006-07-28 07:17:00 +0000121 int offset);
122extern void lcd_remote_puts_style_offset(int x, int y, const unsigned char *str,
123 int style, int offset);
Christian Gmeiner7d984812005-04-25 23:47:51 +0000124extern void lcd_remote_putc(int x, int y, unsigned short ch);
Jens Arnold6a556c12005-06-23 16:53:54 +0000125extern void lcd_remote_stop_scroll(void);
126extern void lcd_remote_scroll_speed(int speed);
127extern void lcd_remote_scroll_delay(int ms);
Jens Arnoldcb36fec2006-07-28 07:17:00 +0000128extern void lcd_remote_puts_scroll(int x, int y, const unsigned char *str);
129extern void lcd_remote_puts_scroll_style(int x, int y, const unsigned char *str,
130 int style);
131extern void lcd_remote_puts_scroll_offset(int x, int y,
132 const unsigned char *str, int offset);
133extern void lcd_remote_puts_scroll_style_offset(int x, int y,
134 const unsigned char *string,
Tomas Salfischberger7fa39df2006-01-22 01:42:05 +0000135 int style, int offset);
136
Jens Arnold6a556c12005-06-23 16:53:54 +0000137extern void lcd_remote_update(void);
Jens Arnold576908d2005-06-29 01:39:50 +0000138extern void lcd_remote_update_rect(int x, int y, int width, int height);
Dave Chapman945c8a22008-01-07 20:34:11 +0000139extern void lcd_remote_update_viewport(void);
140extern void lcd_remote_update_viewport_rect(int x, int y, int width, int height);
Christian Gmeiner7d984812005-04-25 23:47:51 +0000141
Jens Arnold6a556c12005-06-23 16:53:54 +0000142extern void lcd_remote_set_invert_display(bool yesno);
143extern void lcd_remote_set_flip(bool yesno);
Jens Arnold576908d2005-06-29 01:39:50 +0000144
145extern void lcd_remote_set_drawmode(int mode);
146extern int lcd_remote_get_drawmode(void);
Christian Gmeiner7d984812005-04-25 23:47:51 +0000147extern void lcd_remote_setmargins(int xmargin, int ymargin);
148extern int lcd_remote_getxmargin(void);
149extern int lcd_remote_getymargin(void);
Dave Chapman945c8a22008-01-07 20:34:11 +0000150extern int lcd_remote_getwidth(void);
151extern int lcd_remote_getheight(void);
Jens Arnold6a556c12005-06-23 16:53:54 +0000152extern void lcd_remote_setfont(int font);
Dave Chapman3646c312008-01-08 01:22:14 +0000153extern int lcd_remote_getfont(void);
Jens Arnold6a556c12005-06-23 16:53:54 +0000154extern int lcd_remote_getstringsize(const unsigned char *str, int *w, int *h);
Jens Arnold576908d2005-06-29 01:39:50 +0000155
Jens Arnoldcb36fec2006-07-28 07:17:00 +0000156/* low level drawing function pointer arrays */
Jens Arnold11e2e562006-11-26 14:26:08 +0000157#if LCD_REMOTE_DEPTH > 1
158extern lcd_remote_pixelfunc_type* const *lcd_remote_pixelfuncs;
159extern lcd_remote_blockfunc_type* const *lcd_remote_blockfuncs;
160#else
Jens Arnoldcb36fec2006-07-28 07:17:00 +0000161extern lcd_remote_pixelfunc_type* const lcd_remote_pixelfuncs[8];
162extern lcd_remote_blockfunc_type* const lcd_remote_blockfuncs[8];
Jens Arnold11e2e562006-11-26 14:26:08 +0000163#endif
Jens Arnoldcb36fec2006-07-28 07:17:00 +0000164
Christian Gmeiner7d984812005-04-25 23:47:51 +0000165extern void lcd_remote_drawpixel(int x, int y);
Jens Arnold6a556c12005-06-23 16:53:54 +0000166extern void lcd_remote_drawline(int x1, int y1, int x2, int y2);
Jens Arnold576908d2005-06-29 01:39:50 +0000167extern void lcd_remote_hline(int x1, int x2, int y);
168extern void lcd_remote_vline(int x, int y1, int y2);
169extern void lcd_remote_drawrect(int x, int y, int width, int height);
170extern void lcd_remote_fillrect(int x, int y, int width, int height);
Jens Arnoldcb36fec2006-07-28 07:17:00 +0000171extern void lcd_remote_bitmap_part(const fb_remote_data *src, int src_x,
Jens Arnold576908d2005-06-29 01:39:50 +0000172 int src_y, int stride, int x, int y,
173 int width, int height);
Jens Arnoldcb36fec2006-07-28 07:17:00 +0000174extern void lcd_remote_bitmap(const fb_remote_data *src, int x, int y,
Jens Arnold576908d2005-06-29 01:39:50 +0000175 int width, int height);
Jens Arnoldcb36fec2006-07-28 07:17:00 +0000176extern void lcd_remote_putsxy(int x, int y, const unsigned char *str);
Jens Arnold576908d2005-06-29 01:39:50 +0000177
Christian Gmeiner7d984812005-04-25 23:47:51 +0000178extern void lcd_remote_bidir_scroll(int threshold);
179extern void lcd_remote_scroll_step(int pixels);
Linus Nielsen Feltzinga6a01902005-04-15 09:42:12 +0000180
Jens Arnoldcb36fec2006-07-28 07:17:00 +0000181#if LCD_REMOTE_DEPTH > 1
182extern void lcd_remote_set_foreground(unsigned foreground);
183extern unsigned lcd_remote_get_foreground(void);
184extern void lcd_remote_set_background(unsigned background);
185extern unsigned lcd_remote_get_background(void);
186extern void lcd_remote_set_drawinfo(int mode, unsigned foreground,
187 unsigned background);
Nicolas Pennequin7fdfa562007-04-25 21:44:56 +0000188void lcd_remote_set_backdrop(fb_remote_data* backdrop);
189fb_remote_data* lcd_remote_get_backdrop(void);
Jens Arnoldcb36fec2006-07-28 07:17:00 +0000190
191extern 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);
194extern void lcd_remote_mono_bitmap(const unsigned char *src, int x, int y,
195 int width, int height);
196extern 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);
200extern 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 Arnoldd7f94392005-07-07 00:05:29 +0000203#define lcd_remote_mono_bitmap lcd_remote_bitmap
204#define lcd_remote_mono_bitmap_part lcd_remote_bitmap_part
Jens Arnoldcb36fec2006-07-28 07:17:00 +0000205#endif /* LCD_REMOTE_DEPTH */
Jens Arnoldd7f94392005-07-07 00:05:29 +0000206
Linus Nielsen Feltzinga6a01902005-04-15 09:42:12 +0000207#endif
Jens Arnoldcb36fec2006-07-28 07:17:00 +0000208#endif /* __LCD_REMOTE_H__ */