summaryrefslogtreecommitdiff
path: root/firmware/target/arm/olympus/mrobe-500/lcd-mr500.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/olympus/mrobe-500/lcd-mr500.c')
-rw-r--r--firmware/target/arm/olympus/mrobe-500/lcd-mr500.c206
1 files changed, 206 insertions, 0 deletions
diff --git a/firmware/target/arm/olympus/mrobe-500/lcd-mr500.c b/firmware/target/arm/olympus/mrobe-500/lcd-mr500.c
new file mode 100644
index 0000000000..5e41b829e1
--- /dev/null
+++ b/firmware/target/arm/olympus/mrobe-500/lcd-mr500.c
@@ -0,0 +1,206 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id: $
9 *
10 * Copyright (C) 2007 by Karl Kurbjun
11 *
12 * Some of this is based on the Cowon A2 Firmware release:
13 * http://www.cowonglobal.com/download/gnu/cowon_pmp_a2_src_1.59_GPL.tar.gz
14 *
15 * All files in this archive are subject to the GNU General Public License.
16 * See the file COPYING in the source tree root for full license agreement.
17 *
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
20 *
21 ****************************************************************************/
22
23#include "config.h"
24#include "cpu.h"
25#include "string.h"
26#include "lcd.h"
27#include "kernel.h"
28#include "memory.h"
29#include "system-target.h"
30
31static volatile bool lcd_on = true;
32volatile bool lcd_poweroff = false;
33/*
34** These are imported from lcd-16bit.c
35*/
36extern unsigned fg_pattern;
37extern unsigned bg_pattern;
38
39bool lcd_enabled(void)
40{
41 return lcd_on;
42}
43
44/* LCD init - based on code from ingenient-bsp/bootloader/board/dm320/splash.c
45 * and code by Catalin Patulea from the M:Robe 500i linux port
46 */
47void lcd_init_device(void)
48{
49 unsigned int addr;
50
51 /* Clear the Frame */
52 memset16(FRAME, 0x0000, LCD_WIDTH*LCD_HEIGHT);
53
54 outw(0x00ff, IO_OSD_MODE);
55 outw(0x0002, IO_OSD_VIDWINMD);
56 outw(0x2001, IO_OSD_OSDWINMD0);
57 outw(0x0002, IO_OSD_OSDWINMD1);
58 outw(0x0000, IO_OSD_ATRMD);
59 outw(0x0000, IO_OSD_RECTCUR);
60
61 outw((480*2) / 32, IO_OSD_OSDWIN0OFST);
62 addr = ((int)FRAME-CONFIG_SDRAM_START) / 32;
63 outw(addr >> 16, IO_OSD_OSDWINADH);
64 outw(addr & 0xFFFF, IO_OSD_OSDWIN0ADL);
65
66 outw(80, IO_OSD_BASEPX);
67 outw(2, IO_OSD_BASEPY);
68
69 outw(0, IO_OSD_OSDWIN0XP);
70 outw(0, IO_OSD_OSDWIN0YP);
71 outw(480, IO_OSD_OSDWIN0XL);
72 outw(640, IO_OSD_OSDWIN0YL);
73}
74
75/* Update a fraction of the display. */
76void lcd_update_rect(int x, int y, int width, int height)
77{
78 fb_data *dst, *src;
79
80 if (!lcd_on)
81 return;
82
83 if (x + width > LCD_WIDTH)
84 width = LCD_WIDTH - x; /* Clip right */
85 if (x < 0)
86 width += x, x = 0; /* Clip left */
87 if (width <= 0)
88 return; /* nothing left to do */
89
90 if (y + height > LCD_HEIGHT)
91 height = LCD_HEIGHT - y; /* Clip bottom */
92 if (y < 0)
93 height += y, y = 0; /* Clip top */
94 if (height <= 0)
95 return; /* nothing left to do */
96
97 dst = (fb_data *)FRAME + LCD_WIDTH*y + x;
98 src = &lcd_framebuffer[y][x];
99
100 /* Copy part of the Rockbox framebuffer to the second framebuffer */
101 if (width < LCD_WIDTH)
102 {
103 int y;
104 /* Not full width - do line-by-line */
105 for(y=0;y<height;y++)
106 {
107 memcpy(dst, src, width*sizeof(fb_data));
108 dst+=LCD_WIDTH;
109 src+=LCD_WIDTH;
110 }
111 }
112 else
113 {
114 /* Full width - copy as one line */
115 memcpy(dst, src, LCD_WIDTH*height*sizeof(fb_data));
116 }
117}
118
119void lcd_enable(bool state)
120{
121 (void)state;
122}
123
124/* Update the display.
125 This must be called after all other LCD functions that change the display. */
126void lcd_update(void)
127{
128 if (!lcd_on)
129 return;
130
131 memcpy((fb_data *)FRAME, &lcd_framebuffer[0][0],
132 LCD_WIDTH*LCD_HEIGHT*sizeof(fb_data));
133}
134
135/* Line write helper function for lcd_yuv_blit. Write two lines of yuv420. */
136extern void lcd_write_yuv420_lines(fb_data *dst,
137 unsigned char chroma_buf[LCD_HEIGHT/2*3],
138 unsigned char const * const src[3],
139 int width,
140 int stride);
141/* Performance function to blit a YUV bitmap directly to the LCD */
142/* For the Gigabeat - show it rotated */
143/* So the LCD_WIDTH is now the height */
144void lcd_yuv_blit(unsigned char * const src[3],
145 int src_x, int src_y, int stride,
146 int x, int y, int width, int height)
147{
148 /* Caches for chroma data so it only need be recaculated every other
149 line */
150 unsigned char chroma_buf[LCD_HEIGHT/2*3]; /* 480 bytes */
151 unsigned char const * yuv_src[3];
152 off_t z;
153
154 if (!lcd_on)
155 return;
156
157 /* Sorry, but width and height must be >= 2 or else */
158 width &= ~1;
159 height >>= 1;
160
161 fb_data *dst = (fb_data*)FRAME + x * LCD_WIDTH + (LCD_WIDTH - y) - 1;
162
163 z = stride*src_y;
164 yuv_src[0] = src[0] + z + src_x;
165 yuv_src[1] = src[1] + (z >> 2) + (src_x >> 1);
166 yuv_src[2] = src[2] + (yuv_src[1] - src[1]);
167
168 do
169 {
170 lcd_write_yuv420_lines(dst, chroma_buf, yuv_src, width,
171 stride);
172 yuv_src[0] += stride << 1; /* Skip down two luma lines */
173 yuv_src[1] += stride >> 1; /* Skip down one chroma line */
174 yuv_src[2] += stride >> 1;
175 dst -= 2;
176 }
177 while (--height > 0);
178}
179
180void lcd_set_contrast(int val) {
181 (void) val;
182 // TODO:
183}
184
185void lcd_set_invert_display(bool yesno) {
186 (void) yesno;
187 // TODO:
188}
189
190void lcd_blit(const fb_data* data, int bx, int y, int bwidth,
191 int height, int stride)
192{
193 (void) data;
194 (void) bx;
195 (void) y;
196 (void) bwidth;
197 (void) height;
198 (void) stride;
199 //TODO:
200}
201
202void lcd_set_flip(bool yesno) {
203 (void) yesno;
204 // TODO:
205}
206