diff options
author | Marcoen Hirschberg <marcoen@gmail.com> | 2006-12-29 02:49:12 +0000 |
---|---|---|
committer | Marcoen Hirschberg <marcoen@gmail.com> | 2006-12-29 02:49:12 +0000 |
commit | 295367686ec9855c4d90f68a6003e819fef8e7ab (patch) | |
tree | b4077ffb8d2283bf199ad12a90322be77040c2fd /firmware/target/arm/gigabeat/meg-fx/lcd-meg-fx.c | |
parent | 995a804defda23233ccbdd859023f4ba3ecba0bf (diff) | |
download | rockbox-295367686ec9855c4d90f68a6003e819fef8e7ab.tar.gz rockbox-295367686ec9855c4d90f68a6003e819fef8e7ab.zip |
merge a big part of the unofficial gigabeat cvs back. Includes working bootloader and rockbox with audio.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11850 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/gigabeat/meg-fx/lcd-meg-fx.c')
-rw-r--r-- | firmware/target/arm/gigabeat/meg-fx/lcd-meg-fx.c | 173 |
1 files changed, 169 insertions, 4 deletions
diff --git a/firmware/target/arm/gigabeat/meg-fx/lcd-meg-fx.c b/firmware/target/arm/gigabeat/meg-fx/lcd-meg-fx.c index f193f9806d..df5be43551 100644 --- a/firmware/target/arm/gigabeat/meg-fx/lcd-meg-fx.c +++ b/firmware/target/arm/gigabeat/meg-fx/lcd-meg-fx.c | |||
@@ -1,27 +1,56 @@ | |||
1 | #include "config.h" | 1 | #include "config.h" |
2 | #include <string.h> | ||
2 | #include "cpu.h" | 3 | #include "cpu.h" |
3 | #include "lcd.h" | 4 | #include "lcd.h" |
4 | #include "kernel.h" | 5 | #include "kernel.h" |
5 | #include "system.h" | 6 | #include "system.h" |
6 | #include "string.h" | ||
7 | 7 | ||
8 | void lcd_init_device(void); | 8 | void lcd_init_device(void); |
9 | void lcd_update_rec(int, int, int, int); | 9 | void lcd_update_rec(int, int, int, int); |
10 | void lcd_update(void); | 10 | void lcd_update(void); |
11 | 11 | ||
12 | bool usedmablit = false; | ||
13 | |||
12 | /* LCD init */ | 14 | /* LCD init */ |
13 | void lcd_init_device(void) | 15 | void lcd_init_device(void) |
14 | { | 16 | { |
17 | /* Switch from 555I mode to 565 mode */ | ||
18 | LCDCON5 |= 1 << 11; | ||
19 | |||
15 | } | 20 | } |
16 | 21 | ||
17 | /* Update a fraction of the display. */ | 22 | /* Update a fraction of the display. */ |
18 | void lcd_update_rect(int x, int y, int width, int height) | 23 | void lcd_update_rect(int x, int y, int width, int height) |
19 | { | 24 | { |
20 | (void)x; | 25 | (void)x; |
21 | (void)y; | ||
22 | (void)width; | 26 | (void)width; |
23 | (void)height; | 27 | |
24 | memcpy(FRAME, &lcd_framebuffer, sizeof(lcd_framebuffer)); | 28 | if (usedmablit) |
29 | { | ||
30 | /* Spin waiting for DMA to become available */ | ||
31 | //while (DSTAT0 & (1<<20)) ; | ||
32 | if (DSTAT0 & (1<<20)) return; | ||
33 | |||
34 | /* set DMA dest */ | ||
35 | DIDST0 = (int) FRAME + y * sizeof(fb_data) * LCD_WIDTH; | ||
36 | |||
37 | /* FRAME on AHB buf, increment */ | ||
38 | DIDSTC0 = 0; | ||
39 | DCON0 = (((1<<30) | (1<<28) | (1<<27) | (1<<22) | (2<<20)) | ((height * sizeof(fb_data) * LCD_WIDTH) >> 4)); | ||
40 | |||
41 | /* set DMA source and options */ | ||
42 | DISRC0 = (int) &lcd_framebuffer + (y * sizeof(fb_data) * LCD_WIDTH) + 0x30000000; | ||
43 | DISRCC0 = 0x00; /* memory is on AHB bus, increment addresses */ | ||
44 | |||
45 | /* Activate the channel */ | ||
46 | DMASKTRIG0 = 0x2; | ||
47 | /* Start DMA */ | ||
48 | DMASKTRIG0 |= 0x1; | ||
49 | } | ||
50 | else | ||
51 | { | ||
52 | memcpy((void*)FRAME, &lcd_framebuffer, sizeof(lcd_framebuffer)); | ||
53 | } | ||
25 | } | 54 | } |
26 | 55 | ||
27 | /* Update the display. | 56 | /* Update the display. |
@@ -45,6 +74,138 @@ void lcd_update(void) | |||
45 | #define ROUNDOFFS (127*257) | 74 | #define ROUNDOFFS (127*257) |
46 | 75 | ||
47 | /* Performance function to blit a YUV bitmap directly to the LCD */ | 76 | /* Performance function to blit a YUV bitmap directly to the LCD */ |
77 | /* For the Gigabeat - show it rotated */ | ||
78 | /* So the LCD_WIDTH is now the height */ | ||
79 | void lcd_yuv_blit(unsigned char * const src[3], | ||
80 | int src_x, int src_y, int stride, | ||
81 | int x, int y, int width, int height) | ||
82 | { | ||
83 | width = (width + 1) & ~1; | ||
84 | fb_data *dst = (fb_data*)FRAME + x * LCD_WIDTH + (LCD_WIDTH - y) - 1; | ||
85 | fb_data *dst_last = dst - (height - 1); | ||
86 | |||
87 | for (;;) | ||
88 | { | ||
89 | fb_data *dst_row = dst; | ||
90 | int count = width; | ||
91 | const unsigned char *ysrc = src[0] + stride * src_y + src_x; | ||
92 | int y, u, v; | ||
93 | int red, green, blue; | ||
94 | unsigned rbits, gbits, bbits; | ||
95 | |||
96 | /* upsampling, YUV->RGB conversion and reduction to RGB565 in one go */ | ||
97 | const unsigned char *usrc = src[1] + (stride/CSUB_X) * (src_y/CSUB_Y) | ||
98 | + (src_x/CSUB_X); | ||
99 | const unsigned char *vsrc = src[2] + (stride/CSUB_X) * (src_y/CSUB_Y) | ||
100 | + (src_x/CSUB_X); | ||
101 | int xphase = src_x % CSUB_X; | ||
102 | int rc, gc, bc; | ||
103 | |||
104 | u = *usrc++ - 128; | ||
105 | v = *vsrc++ - 128; | ||
106 | rc = RVFAC * v + ROUNDOFFS; | ||
107 | gc = GVFAC * v + GUFAC * u + ROUNDOFFS; | ||
108 | bc = BUFAC * u + ROUNDOFFS; | ||
109 | |||
110 | do | ||
111 | { | ||
112 | y = *ysrc++; | ||
113 | red = RYFAC * y + rc; | ||
114 | green = GYFAC * y + gc; | ||
115 | blue = BYFAC * y + bc; | ||
116 | |||
117 | if ((unsigned)red > (RYFAC*255+ROUNDOFFS)) | ||
118 | { | ||
119 | if (red < 0) | ||
120 | red = 0; | ||
121 | else | ||
122 | red = (RYFAC*255+ROUNDOFFS); | ||
123 | } | ||
124 | if ((unsigned)green > (GYFAC*255+ROUNDOFFS)) | ||
125 | { | ||
126 | if (green < 0) | ||
127 | green = 0; | ||
128 | else | ||
129 | green = (GYFAC*255+ROUNDOFFS); | ||
130 | } | ||
131 | if ((unsigned)blue > (BYFAC*255+ROUNDOFFS)) | ||
132 | { | ||
133 | if (blue < 0) | ||
134 | blue = 0; | ||
135 | else | ||
136 | blue = (BYFAC*255+ROUNDOFFS); | ||
137 | } | ||
138 | rbits = ((unsigned)red) >> 16 ; | ||
139 | gbits = ((unsigned)green) >> 16 ; | ||
140 | bbits = ((unsigned)blue) >> 16 ; | ||
141 | |||
142 | *dst_row = (rbits << 11) | (gbits << 5) | bbits; | ||
143 | |||
144 | /* next pixel - since rotated, add WIDTH */ | ||
145 | dst_row += LCD_WIDTH; | ||
146 | |||
147 | if (++xphase >= CSUB_X) | ||
148 | { | ||
149 | u = *usrc++ - 128; | ||
150 | v = *vsrc++ - 128; | ||
151 | rc = RVFAC * v + ROUNDOFFS; | ||
152 | gc = GVFAC * v + GUFAC * u + ROUNDOFFS; | ||
153 | bc = BUFAC * u + ROUNDOFFS; | ||
154 | xphase = 0; | ||
155 | } | ||
156 | } | ||
157 | while (--count); | ||
158 | |||
159 | if (dst == dst_last) break; | ||
160 | |||
161 | dst--; | ||
162 | src_y++; | ||
163 | } | ||
164 | } | ||
165 | |||
166 | |||
167 | |||
168 | void lcd_set_contrast(int val) { | ||
169 | (void) val; | ||
170 | // TODO: | ||
171 | } | ||
172 | |||
173 | void lcd_set_invert_display(bool yesno) { | ||
174 | (void) yesno; | ||
175 | // TODO: | ||
176 | } | ||
177 | |||
178 | void lcd_blit(const fb_data* data, int bx, int y, int bwidth, | ||
179 | int height, int stride) | ||
180 | { | ||
181 | (void) data; | ||
182 | (void) bx; | ||
183 | (void) y; | ||
184 | (void) bwidth; | ||
185 | (void) height; | ||
186 | (void) stride; | ||
187 | //TODO: | ||
188 | } | ||
189 | |||
190 | void lcd_set_flip(bool yesno) { | ||
191 | (void) yesno; | ||
192 | // TODO: | ||
193 | } | ||
194 | |||
195 | |||
196 | |||
197 | |||
198 | |||
199 | |||
200 | |||
201 | |||
202 | |||
203 | |||
204 | |||
205 | |||
206 | |||
207 | #if 0 | ||
208 | /* Performance function to blit a YUV bitmap directly to the LCD */ | ||
48 | void lcd_yuv_blit(unsigned char * const src[3], | 209 | void lcd_yuv_blit(unsigned char * const src[3], |
49 | int src_x, int src_y, int stride, | 210 | int src_x, int src_y, int stride, |
50 | int x, int y, int width, int height) | 211 | int x, int y, int width, int height) |
@@ -129,3 +290,7 @@ void lcd_yuv_blit(unsigned char * const src[3], | |||
129 | } | 290 | } |
130 | while (dst < dst_end); | 291 | while (dst < dst_end); |
131 | } | 292 | } |
293 | #endif | ||
294 | |||
295 | |||
296 | |||